This commit is contained in:
gnieark 2015-11-14 23:14:13 +01:00
parent a2a0d9a1a4
commit 6200a1a235
2 changed files with 49 additions and 0 deletions

21
euler5-bis.php Normal file
View File

@ -0,0 +1,21 @@
<?php
/*
* Gnieark's anwser to euler problem 5
* https://projecteuler.net/problem=5
*/
//decrement smaller by 20 and tests
$divisible=false;
$i=0;
while(!$divisible){
$i+=20;
//tester si i est divisible
$divisible=true;
for($j=19;$j>1;$j--){
if(fmod($i,$j)<>0){
$divisible=false;
break;
}
}
}
echo $i;

28
euler5.php Normal file
View File

@ -0,0 +1,28 @@
<?php
/*
* Gnieark's anwser to euler problem 5
* https://projecteuler.net/problem=5
*/
$taller=1;
for ($i=1;$i<21;$i++){
$taller=$taller*$i;
}
//decrement smaller by 20 and test
$smaller=$taller;
for ($i=$taller;$i>0;$i+=-20){
//tester si i est divisible
$divisible=true;
for($j=19;$j>0;$j--){
if(fmod($i,$j)<>0){
$divisible=false;
break;
}
}
if($divisible){
$smaller=$i;
echo $i."\n";
}
}
echo $smaller;