Created
May 20, 2014 11:30
-
-
Save sankars/388224d42cd3e5588998 to your computer and use it in GitHub Desktop.
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
import sys | |
def main(): | |
line = sys.stdin.readline() | |
printFibonacci(line) | |
def printFibonacci(memberCount): | |
if isInt(memberCount): | |
memberCount = int(memberCount) | |
previous = 0 | |
current = 1 | |
tmp = 0 | |
for i in range(0, memberCount, 1): | |
print(previous) | |
tmp = previous | |
previous = current | |
current = previous + tmp | |
else: | |
print("Not a valid input!") | |
def isInt(x): | |
try: | |
int(x) | |
return True | |
except ValueError: | |
return False | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment