Odd Fibonacci Sum

Level pending

All of the Sum of all Odd Fibonacci numbers less than 10 is equal to:

1 + 1 + 3 + 5 = 10 1+1+3+5=10

Find the last three digits of the sum of all odd digits less than Four Million.


The answer is 732.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Lokesh Sharma
Dec 18, 2013

Sol in pYthN:

fib = [1,1]
while fib[-1] < 4000000:
    fib.append(fib[-1] + fib[-2])
del fib[-1]

oddfib = []
for i in fib:
    if i%2 == 1:
        oddfib.append(i)
print sum(oddfib)

The question doesn't make any sense.If we are to accept that the title of the question is what the question wants(In the body of the question,it asks for the sum of odd digits,not fibonacci numbers),even then,the answer should be 010.It is asking for sum of the digits i.e. fibonacci numbers less than 10,which is 010[digits are always between 1 and 9 inclusive]

Rahul Saha - 7 years, 5 months ago

Log in to reply

Very true, the last line is very misleading.

Lokesh Sharma - 7 years, 5 months ago

Log in to reply

You are right! I apologize for that. Your code is admirable though.

Luke Nelson - 7 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...