Last active
August 29, 2015 13:57
-
-
Save kittinan/9347703 to your computer and use it in GitHub Desktop.
Even Fibonacci numbers PHP Solve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* projecteuler.net | |
* Even Fibonacci numbers PHP Solve | |
*/ | |
$previous = 1; | |
$current = 2; | |
$sum_even = $current; | |
while ($current < 4000000) { | |
$next = $current + $previous; | |
if ($next % 2 == 0) { | |
$sum_even += $next; | |
} | |
$previous = $current; | |
$current = $next; | |
} | |
echo "$sum_even\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment