Euler/euler7.php
2015-11-14 23:01:47 +01:00

24 lines
548 B
PHP

<?php
/*
* Gnieark's anwser to euler problem 6
* https://projecteuler.net/problem=6
*/
$primesNumbers=array(2);//ommit 1
$i=3;
while(count($primesNumbers)<10001){
$isPrimaryNumber=true;
$index=0;
while(($primesNumbers[$index]<=sqrt($i)) && $index < count($primesNumbers)){
if(fmod($i,$primesNumbers[$index])==0){
$isPrimaryNumber=false;
break;
}
$index++;
}
if($isPrimaryNumber){
$primesNumbers[]=$i;
echo (count($primesNumbers))." ".$i."\n";
}
$i=$i+2;
}