The classic conditional
Given a number N, print every integer from 1 to N (inclusive).
But:
- If the number is divisible by 3, print
Fizz instead.
- If divisible by 5, print
Buzz.
- If divisible by both, print
FizzBuzz.
Input: 5
Output:
1
2
Fizz
4
Buzz
Constraints
- One value per line.
- Check divisibility with the modulo operator
%.
Ad SpaceGoogle AdSense active for guests & free-tier learners.