Created
February 20, 2018 17:40
-
-
Save Hiddenx/6c403841b78931fd43d10f0f9c2cf04e to your computer and use it in GitHub Desktop.
10001th prime number
This file contains hidden or 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 | |
| $n = 10001; | |
| $final_number = 0; | |
| $count = 0; | |
| for ($i = 3; $count < $n - 1; $i++) { | |
| if ($i % 2 != 1) { | |
| continue; | |
| } | |
| $x = sqrt($i); | |
| $s = 3; | |
| while (($i % $s != 0) && $s < $x) { | |
| $s += 2; | |
| } | |
| if ((($i % $s == 0 && $i != $s) * 1) == 0) { | |
| $final_number = $i; | |
| $count++; | |
| } | |
| } | |
| echo $final_number; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment