Monday, February 01, 2010

Project Euler Problem 2

Project Euler Problem 2: Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.

<?php

$s = $t = 2;
while (($t = round($t * pow((sqrt(5)/2)+0.5, 3)))
< 4000001) $s += $t;
echo $s;

?>

0 Comments...

Post a Comment

 · Blog Index