FizzBuzz with 4 and 6 · FizzBuzz com 4 e 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 com 4 e 6
Um FizzBuzz com uma armadilha.
Teste ambos primeiro, com n % 4 == 0 and n % 6 == 0. Multiplicar os dois números, n % 24 == 0, parece um atalho, mas falha em 12: um número pode ser divisível por 4 e por 6 sem ser divisível por 24.
Print the numbers 1 to · até 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. · Imprima os números 1 a 24, um por linha, mas imprima Fizz para múltiplos de 4, Buzz para múltiplos de 6, e FizzBuzz para números que são múltiplos de ambos.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.