16 lines
382 B
Python
16 lines
382 B
Python
|
G
|
def fb(n):
|
||
|
|
result = []
|
||
|
|
for i in range(1, n + 1):
|
||
|
|
if i % 3 == 0 and i % 5 == 0:
|
||
|
|
result.append('FizzBuzz')
|
||
|
|
elif i % 3 == 0:
|
||
|
|
result.append('Fizz')
|
||
|
|
elif i % 5 == 0:
|
||
|
|
result.append('Buzz')
|
||
|
|
else:
|
||
|
|
result.append(str(i))
|
||
|
|
return result
|
||
|
|
|
||
|
|
# Test the function
|
||
|
|
if __name__ == "__main__":
|
||
|
|
print(fb(15))
|