I ran across this post on reddit.com about some developers who have had some school learnins’and things, they couldn’t even do a fizz buzz question. Now I never heard of this so I decided that I write up some thing that did it. I wrote it up in php and javascript. the javascript portion wasn’t tested though. HA
here is the question they asked on http://www.codinghorror.com/
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
kinda simple I guess. all in the modulus i spose.
php:
echo "<pre>";
$i = 1;
while ($i < 101) {
if($i % 3 == 0 && $i % 5 == 0) {
echo '--FizzBuzz'."\n";
}
elseif($i % 3 == 0) {
echo 'Fizz'."\n";
}
elseif($i % 5 == 0) {
echo 'Buzz'."\n";
}
else {
echo $i."\n";
}
$i++;
}
echo "</pre>";
javascript:
for(i=1; i<101; i++) {
if (i % 3 == 0 && i % 5 == 0 ) {
document.write('FizzBuzz
');
}
else if (i % 3 == 0) {
document.write('Fizz
');
}
else if (i % 5 == 0) {
document.write('Buzz
');
}
else {
document.write(i + '
');
}
}

