Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Created November 19, 2013 07:04
Show Gist options
  • Save pmgupte/7541393 to your computer and use it in GitHub Desktop.
Save pmgupte/7541393 to your computer and use it in GitHub Desktop.
PHP solution to Project Euler problem # 10.
<?php
/**
* Problem 10: Summation of primes
* The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
* Find the sum of all the primes below two million.
*
* Uses GMP - http://www.php.net/manual/en/book.gmp.php
*/
for($prime=2, $sum=0; $prime < 2000000; $sum+=$prime, $prime=gmp_intval(gmp_nextprime($prime)));
echo "Sum of all prime numbers < 2 million is: $sum";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment