Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Created July 31, 2020 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/888efe4b2aee3a1344a6f404dd307ccc to your computer and use it in GitHub Desktop.
Save lbvf50mobile/888efe4b2aee3a1344a6f404dd307ccc to your computer and use it in GitHub Desktop.
Codewars.com: Fibonacci's FizzBuzz.
# 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