Skip to content

Instantly share code, notes, and snippets.

@kittinan
Last active August 29, 2015 13:57
Show Gist options
  • Save kittinan/9347703 to your computer and use it in GitHub Desktop.
Save kittinan/9347703 to your computer and use it in GitHub Desktop.
Even Fibonacci numbers PHP Solve
<?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