Skip to content

Instantly share code, notes, and snippets.

@sankars
Created May 20, 2014 11:30
Show Gist options
  • Save sankars/388224d42cd3e5588998 to your computer and use it in GitHub Desktop.
Save sankars/388224d42cd3e5588998 to your computer and use it in GitHub Desktop.
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