Last active
August 29, 2015 14:00
-
-
Save yuchan/11170222 to your computer and use it in GitHub Desktop.
fizzbuzz
This file contains hidden or 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
#! /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