2015-11-22 22:03:01 +01:00
|
|
|
<?php
|
|
|
|
/*
|
2015-11-25 20:35:23 +01:00
|
|
|
* Gnieark's anwser to euler problem 26
|
|
|
|
* https://projecteuler.net/problem=26
|
2015-11-22 22:03:01 +01:00
|
|
|
*/
|
2015-11-25 20:35:23 +01:00
|
|
|
$beastDenominateur=0;
|
|
|
|
$longestCycle=0;
|
|
|
|
for ($denominateur=2; $denominateur < 1000; $denominateur ++){
|
|
|
|
|
|
|
|
$reste=1;
|
|
|
|
$restes=array();
|
|
|
|
$count=0;
|
|
|
|
while (!in_array($reste,$restes)){
|
|
|
|
$restes[]=$reste;
|
|
|
|
$reste=$reste*10;
|
|
|
|
$reste=fmod($reste,$denominateur);
|
2015-11-22 22:16:01 +01:00
|
|
|
$count++;
|
2015-11-25 20:35:23 +01:00
|
|
|
}
|
|
|
|
if($count > $longestCycle){
|
|
|
|
$longestCycle=$count;
|
|
|
|
$beastDenominateur=$denominateur;
|
|
|
|
}
|
2015-11-22 22:16:01 +01:00
|
|
|
}
|
|
|
|
|
2015-11-25 20:35:23 +01:00
|
|
|
echo $beastDenominateur."\n";
|