Created
April 11, 2015 08:57
-
-
Save gumeniukcom/f530615f34409f6a025e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Stan Gumeniuk [email protected] | |
*/ | |
function getPrimeNumbers($n = 100) | |
{ | |
$resheto = []; | |
$current = 2; | |
$build = 1; | |
while((count($resheto)+1)<=$n){ | |
foreach($resheto as $prime){ | |
if ($current%$prime!=0){ | |
$build++; | |
} | |
} | |
if (count($resheto)+1==$build){ | |
$resheto[] = $current; | |
} | |
$build = 1; | |
$current++; | |
} | |
return $resheto; | |
} | |
var_dump(getPrimeNumbers(10)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment