25
This commit is contained in:
parent
c30b264fa5
commit
f2e07f9a03
37
euler25.php
37
euler25.php
|
@ -1,26 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Gnieark's anwser to euler problem 25
|
* Gnieark's anwser to euler problem 26
|
||||||
* https://projecteuler.net/problem=25
|
* https://projecteuler.net/problem=26
|
||||||
*/
|
*/
|
||||||
|
$beastDenominateur=0;
|
||||||
|
$longestCycle=0;
|
||||||
|
for ($denominateur=2; $denominateur < 1000; $denominateur ++){
|
||||||
|
|
||||||
//see https://fr.wikipedia.org/wiki/Suite_de_Fibonacci#Avec_la_formule_de_Binet
|
$reste=1;
|
||||||
echo intval((log(10)*999 + (log(5)/2) ) / log(1.61803398875)) +1;
|
$restes=array();
|
||||||
|
$count=0;
|
||||||
/*
|
while (!in_array($reste,$restes)){
|
||||||
Very long solution that didn't test :
|
$restes[]=$reste;
|
||||||
|
$reste=$reste*10;
|
||||||
$i=1;
|
$reste=fmod($reste,$denominateur);
|
||||||
$j=2;
|
|
||||||
$count=2;
|
|
||||||
while(strlen($i)<1000){
|
|
||||||
$new=gmp_add($i,$j);
|
|
||||||
$i=$j;
|
|
||||||
$j=$new;
|
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
if($count > $longestCycle){
|
||||||
|
$longestCycle=$count;
|
||||||
|
$beastDenominateur=$denominateur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $beastDenominateur."\n";
|
||||||
echo $count;
|
|
||||||
|
|
||||||
*/
|
|
Loading…
Reference in New Issue
Block a user