HarryCoops
7/20/2015 - 4:43 PM

n_numbers_of_fib.py

# generator function for the fibonacci sequence
def fibonacci():
	a, b = 0, 1
	while True:
		yield a
		a, b = b, a + b

def main():
	term = int(input('nth term:'))

	for index, i in enumerate(fibonacci()):
		if index <= term:
			print(i)
		else:
			break

if __name__ == '__main__':
	main()