aboutsummaryrefslogtreecommitdiff
path: root/entries/jjhickmon/fibonacci.py
blob: 7e9f5f6a9bdcda101e0602bf3cf90ae0a149ade2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def fib(index):
	if (index < 0):
		raise IndexError("Error: index must be >= 0")

	prev = 1
	curr = 1
	for _ in range(index - 1):
		temp = curr
		curr += prev
		prev = temp
	return curr

if __name__ == "__main__":
	print(fib(5))