dimanche 4 janvier 2015

Why can't I solve this alternate FizzBuzz solution this way?


Given x, if it is divisible by 3, print fizz; if it is divisible by 6, print buzz; if it is divisible by 3 and 6, print fizzbuzz.


Why can't I use 15 like I do in the original problem where I have 3 and 5?



if ( x mod 18 == 0 )
{
print fizzbuzz
} else if (x mod 3 == 0)
{
print fizz
}
else if (x mod 6 == 0)
{
print buzz
}




Aucun commentaire:

Enregistrer un commentaire