Project Euler.net Answers
Problem 7
Solved on 2/29/2008
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?
$p = 2;
$pw = 10001;
for($ic = 6; $p <= $pw; $ic+=6){
if($this->isPrime($ic-1)){
$p++;
if ($p == $pw) $answer = $ic-1;
}
if($this->isPrime($ic+1)){
$p++;
if ($p == $pw) $answer = $ic+1;
}
}
answer = 104,743