mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
19 lines
466 B
Python
19 lines
466 B
Python
class Solution(object):
|
|
def fizzBuzz(self, n):
|
|
"""
|
|
:type n: int
|
|
:rtype: List[str]
|
|
"""
|
|
array = []
|
|
|
|
for i in range(1, n + 1):
|
|
if i % 15 == 0:
|
|
array.append("FizzBuzz")
|
|
elif i % 3 == 0:
|
|
array.append("Fizz")
|
|
elif i % 5 == 0:
|
|
array.append("Buzz")
|
|
else:
|
|
array.append(str(i))
|
|
|
|
return array; |