Project Euler #2: Even Fibonacci numbers

  • + 5 comments

    This question actually has an easy logic. Lets the fibonacci series:1 1 2 3 5 8 13 21 34 55 89 144

    Now separate the even numbers :- 2 8 34 144

    • 8 = 2*4 + 0
    • 34 = 8*4 + 2
    • 144 = 34*4 + 8
    • 610 = 144*4 + 34

    GENERAL FORM

    • beginning = 2
    • previous = 0
    • IN LOOP:
    • (next_even) = beginning * 4 + previous
    • //calcuate sum
    • previous = beginning
    • beginning = next_even