Created
October 15, 2016 00:10
-
-
Save SahilKadam/72755e1465755a20b03c1db141c98a19 to your computer and use it in GitHub Desktop.
Write a program that, given a number n from STDIN, prints out all numbers from 1 to n (inclusive) to STDOUT, each on their own line. But there's a catch: For numbers divisible by 3, instead of n, print Fizz For numbers divisible by 5, instead of n, print Buzz For numbers divisible by 3 and 5, just print FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input().strip()) | |
for i in range(1,n+1): | |
if i%3 == 0 and i%5 == 0: | |
print ("FizzBuzz") | |
elif i % 3 == 0: | |
print ("Fizz") | |
elif i % 5 == 0: | |
print ("Buzz") | |
else: | |
print (i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment