.
This commit is contained in:
commit
a6d766562c
13
euler1.php
Normal file
13
euler1.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/*
|
||||
* Gnieark's anwser to euler problem 1
|
||||
* https://projecteuler.net/problem=1
|
||||
*/
|
||||
$sum=0;
|
||||
for ($i=2;$i<1000;$i++){
|
||||
if((fmod($i,3)==0) OR (fmod($i,5)==0)){
|
||||
$sum=$sum+$i;
|
||||
}
|
||||
}
|
||||
|
||||
echo $sum;
|
19
euler2.php
Normal file
19
euler2.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?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;
|
Loading…
Reference in New Issue
Block a user