re: Project Euler #2 - Even Fibonacci numbers VIEW POST

FULL DISCUSSION
 

Solved a few of the Euler challenges a few years ago (when I was still in high school, because what else would you do?) using PHP.

Solution: 4613732

$sum = 0;
$curr = 2;
$prev = 1;
$goal = 4000000;
while ($curr < $goal) {
if($curr % 2 == 0) {
$sum += $curr;
}
$tmp = $prev;
$prev = $curr;
$curr += $tmp;
}
echo $sum;

code of conduct - report abuse