Euler/euler26.php

25 lines
507 B
PHP
Raw Permalink Normal View History

2015-11-25 20:48:18 +01:00
<?php
/*
* Gnieark's anwser to euler problem 26
* https://projecteuler.net/problem=26
*/
$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);
$count++;
}
if($count > $longestCycle){
$longestCycle=$count;
$beastDenominateur=$denominateur;
}
}
echo $beastDenominateur."\n";