Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Created November 19, 2013 07:02
Show Gist options
  • Select an option

  • Save pmgupte/7541373 to your computer and use it in GitHub Desktop.

Select an option

Save pmgupte/7541373 to your computer and use it in GitHub Desktop.
PHP solution to Project Euler problem # 7.
<?php
/**
* Problem 7: 10001st prime
* By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
* What is the 10001st prime number?
*
* Uses GMP - http://www.php.net/manual/en/book.gmp.php
*/
for($count = 0, $prime=0; $count < 10001; $prime=gmp_intval(gmp_nextprime($prime)), $count++);
echo "10001st prime number is: $prime";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment