Created
July 31, 2020 20:29
-
-
Save lbvf50mobile/888efe4b2aee3a1344a6f404dd307ccc to your computer and use it in GitHub Desktop.
Codewars.com: Fibonacci's 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
# https://www.codewars.com/kata/57bf599f102a39bb1e000ae5 Fibonacci's FizzBuzz. | |
def fibs_fizz_buzz(n): | |
if 1 == n: return [1] | |
if 2 == n: return [1,1] | |
a,b,i = 1,1,2 | |
ans = [1,1] | |
while i < n: | |
new_b = a+b | |
a,b = b,new_b | |
if 0 == new_b%15: new_b = "FizzBuzz" | |
elif 0 == new_b%3: new_b = "Fizz" | |
elif 0 == new_b%5: new_b = "Buzz" | |
i += 1 | |
ans.append(new_b) | |
return ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment