Project Euler problem 2.

This commit is contained in:
sweatshirt0 2023-01-22 13:29:37 -05:00
parent 8b6e6959cf
commit 354fa17588
1 changed files with 22 additions and 0 deletions

22
PE2.php Normal file
View File

@ -0,0 +1,22 @@
<?php
$pre = 0;
$cur = 1;
$nex = 0;
$s = 0;
$cap = 4000000;
while ($cur <= $cap) {
$nex = $pre + $cur;
$pre = $cur;
$cur = $nex;
if ($cur % 2 == 0) {
$s = $s + $cur;
}
}
echo $s . "\n";
?>