Skip to content · ⁨דלג לתוכן⁩

FizzBuzz · ⁨פיזבאז⁩

English

FizzBuzz

The classic. Walk the numbers 1 to n and, for each, decide what string to add to a list:

  • divisible by both 3 and 5 → FizzBuzz
  • divisible by 3 → Fizz
  • divisible by 5 → Buzz
  • otherwise → the number itself, as a string

Check the "both" case first, or a multiple of 15 will be caught by the 3 test alone.

עברית

FizzBuzz

הקלאסי. עבור על המספרים 1 עד n, ולכל אחד מהם החלט איזה מחרוזת להוסיף לרשימה:

  • מתחלק ב-שתי 3 ו-5 → FizzBuzz
  • מתחלק ב-3 → Fizz
  • מתחלק ב-5 → Buzz
  • אחרת → המספר עצמו, כמחרוזת

בדוק את המקרה "שתי" תחילה, או שמאMultiple של 15 יתפס רק על ידי בדיקת 3.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP