FizzBuzz with 4 and 6 · 4와 6을 사용한FizzBuzz
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.
4와 6을 사용한FizzBuzz
함정이 있는 FizzBuzz입니다.
먼저 n % 4 == 0 and n % 6 == 0으로 두 가지 조건 모두를 테스트하십시오. 두 수를 곱한 n % 24 == 0은捷径(shortcut)처럼 보이지만 12을 놓칩니다: 어떤 수는 4와 6으로 나누어지는 데도 24로 나누어지지 않을 수 있습니다.
Print the numbers 1 to 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. · 숫자 1부터 24까지 한 줄에 하나씩 출력하되, 4의 배수는 Fizz, 6의 배수는 Buzz, 둘 다 배수인 경우에는 FizzBuzz를 출력합니다.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.