Project Euler.net Answers
Problem 10
Solved on 2/26/2008
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
Note: This problem has been changed recently, please check that you are using the right parameters.
0
$number = (int)$this->getRequestParameter('number');
$sum = 5;
if($number <= 2000000 && $number >= 3){
for($ic = 6; $ic <= $number+1; $ic+=6){
if($this->isPrime($ic-1)) $sum+= $ic-1;
if($ic <= $number && $this->isPrime($ic+1)) $sum+= $ic+1;
}
}
public function isPrime($val){
if(($val % 2 ) == 0) return FALSE;
for($c = 3; $c <= sqrt($val); $c+=2) {
if(($val % $c ) == 0) return FALSE;
}
return TRUE;
}
Feb. 11, 2008
Wells Ideas Inc. launches their redesigned site.
The site is built on a symfony platform and utilizes client information from their project management site.
Wells Ideas Inc. launches their redesigned site.
The site is built on a symfony platform and utilizes client information from their project management site.
"The greatest challenge to any thinker is stating the problem in a way that will allow a solution."
- Bertrand Russell
- Bertrand Russell
Wells Ideas © 2007 | 1-973-769-9108 | info@wellsideas.com
Contact Us | Site Map | Open Source Solutions | Templates | Client Login
Contact Us | Site Map | Open Source Solutions | Templates | Client Login
