.
This commit is contained in:
parent
a2a0d9a1a4
commit
6200a1a235
21
euler5-bis.php
Normal file
21
euler5-bis.php
Normal 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
28
euler5.php
Normal 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;
|
Loading…
Reference in New Issue
Block a user