Skip to content

Instantly share code, notes, and snippets.

@yuchan
Last active August 29, 2015 14:00
Show Gist options
  • Save yuchan/11170222 to your computer and use it in GitHub Desktop.
Save yuchan/11170222 to your computer and use it in GitHub Desktop.
fizzbuzz
#! /usr/bin/env python
def fb(n):
dic = {}
for num in range(1, n+1):
dic[num] = ""
for num in range(3, n+1)[::3]:
dic[num] += "Fizz"
for num in range(5, n+1)[::5]:
dic[num] += "Buzz"
return dic[n]
i = 1
while i <= 20:
print i, fb(i)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment