From 55afed209b9da9c6a85891207a043c439448717c Mon Sep 17 00:00:00 2001 From: gnieark Date: Sun, 15 Nov 2015 23:53:52 +0100 Subject: [PATCH] bug fix --- _functions.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/_functions.php b/_functions.php index 768697a..510501a 100644 --- a/_functions.php +++ b/_functions.php @@ -23,15 +23,14 @@ function getPrimeNumber($order){ while (count($primeNumbersList) < $order){ $isPrimaryNumber=true; - foreach($primeNumbersList as $pr){ - - if($pr>sqrt($i)){ - break; - } - if(fmod($i,$pr)==0){ + $index=0; + + while(($primeNumbersList[$index]<=sqrt($i)) && $index < count($primeNumbersList)){ + if(fmod($i,$primeNumbersList[$index])==0){ $isPrimaryNumber=false; break; } + $index++; } if($isPrimaryNumber){ $primeNumbersList[]=$i;