So two of my New Years resolutions are to challenge myself and write more on this blog. So I found the Fizz Buzz challenge over at Code Dojo and thought I would kill two birds with one stone here.
I thought I would share how I completed the Fizz Buzz challenge, I could go further and loop through some more numbers however the challenge of states divisible by 3,5 and 15 not any other numbers.
if($number %15 == 0) {
echo ‘fizzbuzz’;
} elseif($number %3 == 0) {
echo ‘fizz’;
} elseif($number %5 == 0) {
echo ‘buzz’;
} else {
echo $number;
}
}
echo fizzer(15);
I would love to see some more solutions in other languages so please tweet or if you find this on hacker news comment back with some examples.
Thanks