Project Euler Challenge #2 : Fibonacci Sums

Thursday, July 24, 2014

Another straightforward challenge: find the sum of all even numbers in the Fibonacci sequence less than four million.

 def even_fib_sum(limit = 10):
	num = 2
	pre = 1
	tot = 2
	while num < limit:
		num += pre
		pre = num - pre
		if num % 2 == 0:
			tot += num
	return tot

Yeah, yawn.

Comments are closed, but you can leave a trackback.