Skip to content

Instantly share code, notes, and snippets.

@kazua
Created October 8, 2013 13:39
Show Gist options
  • Save kazua/6884821 to your computer and use it in GitHub Desktop.
Save kazua/6884821 to your computer and use it in GitHub Desktop.
Project Euler Problem 2(PHP)
<?php
//write kazua
$num1 = 1;
$num2 = 1;
$result = 0;
$i = 0;
while ($i < 4000000) {
if ($i % 2 === 0) $result += $i;
$i = $num1 + $num2;
$num2 = $num1;
$num1 = $i;
}
echo $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment