FizzBuzz with 4 and 6 · FizzBuzz con 4 y 6
FizzBuzz with 4 and 6
A FizzBuzz with a trap in it.
Test for both first, with n % 4 == 0 and n % 6 == 0. Multiplying the two numbers, n % 24 == 0, looks like a shortcut but misses 12: a number can divide by 4 and by 6 without dividing by 24.
FizzBuzz con 4 y 6
Un FizzBuzz con una trampa en él.
Prueba ambas condiciones primero, con n % 4 == 0 and n % 6 == 0. Multiplicar los dos números, n % 24 == 0, parece un atajo pero falla al no capturar 12: un número puede ser divisible entre 4 y entre 6 sin ser divisible entre 24.
Print the numbers 1 to · hasta 24, one per line, but print Fizz for multiples of 4, Buzz for multiples of 6, and FizzBuzz for numbers that are multiples of both. · Imprime los números 1 a 24, uno por línea, pero imprime Fizz para los múltiplos de 4, Buzz para los múltiplos de 6, y FizzBuzz para los números que son múltiplos de ambos.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.