Skip to content
Snippets Groups Projects
Commit f55f947e authored by nimrod's avatar nimrod
Browse files

Merge branch 'master' of github.com:noamknispel/ThePrimeBenchMark

parents 420fb32b 27f9b979
No related branches found
No related tags found
No related merge requests found
<?php
function isPrime($num) {
$root = sqrt($num);
if((int) $root == $root ) {
return false;
}
for($i=2;$i<$root;$i++) {
if($num%$i==0) {
return false;
}
}
return true;
}
if(isset($argv[1])) {
$num = $argv[1];
$primes = array();
$i = 0;
while(count($primes) < $num) {
if(isPrime($i)) {
$primes[] = $i;
}
$i++;
}
echo join(",",$primes);
// echo count($primes);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment