โ Back to Loops
Question 335
FizzBuzz 1 to N
FizzBuzz 1 to N
Read an integerNfrom input. Use a loop over 1..N and print, one per line:FizzBuzzif the number is divisible by both 3 and 5, otherwiseFizzif divisible by 3, otherwiseBuzzif divisible by 5, otherwise the number itself. For input5the exact output is: 1 2 Fizz 4 Buzz
Expected Output:
1 2 Fizz 4 Buzz
Topics:
Loops
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.