FizzBuzz with 4 and 6 · פיזבאז עם 4 ו-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 עם 4 ו-6
FizzBuzz עם קונדום בתוכו.
בדוק את שניהם תחילה, עם n % 4 == 0 and n % 6 == 0. הכפלת שני המספרים, n % 24 == 0, נראית כמו קיצור דרך אך מחמיצה 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, אחד בכל שורה, אך הדפס Fizz עבור כפלות של 4, Buzz עבור כפלות של 6, ו-FizzBuzz עבור מספרים שהם כפלה של שניהם.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.