This commit is contained in:
gnieark 2015-11-14 23:01:47 +01:00
parent 7b6f0aeedb
commit a2a0d9a1a4

24
euler7.php Normal file
View File

@ -0,0 +1,24 @@
<?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;
}