Skip to content · ⁨Pular para o conteúdo⁩

FizzBuzz with 4 and 6 · ⁨FizzBuzz com 4 e 6⁩

English

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.

Português

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.

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP