Multiple of 3:
(1) Input: 6 Output: 3
1 9
2 6
3
5
9
6
(2) Input: 4 Output: 3
1 6
3
6
8
def fizz_buzz(num):
if num%3==0 and num%5==0:
return 'FizzBuzz'
elif num % 3 == 0:
return 'Fizz'
elif num % 5==0:
return 'Buzz'
else:
return num
for n in range(1,100):
print(fizz_buzz(n))
Comments
Leave a comment