Claus Witt

software and web developer

Archive for the ‘euler’ tag

Project Euler Problem Two

with 2 comments

Yesterday I posted my first euler-code. This time we will take a look at problem two, again with the help of some javascript running on node.js.

The problem is “Find the sum of all the even-valued terms in the [fibonacci] sequence which do not exceed four million.”

My take on the solution was to run through all fibonacci numbers below 4.000.000 and adding them to the total, if they were equal. The next fibonacci number is calculated by always saving the last two numbers found.

You will need node.js to run this code.

Written by Claus Witt

May 30th, 2010 at 10:00 am