FizzBuzz
Easy 20 XPLoopsConditions
Commonly asked at Microsoft, Amazon
Read n. For each number from 1 to n print Fizz if it is divisible by 3, Buzz if divisible by 5, FizzBuzz if divisible by both, otherwise the number itself.
- Input
- One integer n.
- Output
- n lines.
Sample 1
Input
5
Output
1 2 Fizz 4 Buzz
Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The solution unlocks after 3 submissions.