shorter
This commit is contained in:
parent
513f500b22
commit
e8c94739fa
21
euler07.php
21
euler07.php
|
@ -3,22 +3,5 @@
|
|||
* 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;
|
||||
}
|
||||
require_once("_functions.php");
|
||||
echo getPrimeNumber(10001);
|
Loading…
Reference in New Issue
Block a user