Thursday, 11 September 2008

Second project Euler problem solved

This takes advantage of the fact that every third Fibonacci number is even in order to avoid having to check for each number f it is even.

a=1
b=1
c=2
x=0
while c < 4000000:
    x=x+c
    a=b+c
    b=a+c
    c=a+b
print x

If you found this little bit of code helpful, then please consider donating so that I can continue coding.

You can donate here

No comments: