You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
228 B
PHTML
19 lines
228 B
PHTML
9 years ago
|
<?php
|
||
|
/*
|
||
|
* Gnieark's anwser to euler problem 2
|
||
|
* https://projecteuler.net/problem=2
|
||
|
*/
|
||
|
$i=1;
|
||
|
$j=2;
|
||
|
$sum=0;
|
||
|
while($i<4000000){
|
||
|
if(fmod($j,2)==0){
|
||
|
$sum+=$j;
|
||
|
}
|
||
|
$new=$i+$j;
|
||
|
$i=$j;
|
||
|
$j=$new;
|
||
|
}
|
||
|
|
||
|
|
||
|
echo $sum;
|