Commit f55f947e authored by nimrod's avatar nimrod
Browse files

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

parents 420fb32b 27f9b979
Loading
Loading
Loading
Loading

prime.php

0 → 100644
+32 −0
Original line number Diff line number Diff line
<?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);
}