Project Euler.net Answers
Problem 3
Solved on 2/29/2008
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Note: This problem has been changed recently, please check that you are using the right number.
$number = 600851475143;
for($ic = 2; $ic <= sqrt($number); $ic++){
$thisint = $number / $ic;
$string = strval($thisint);
$isint = strpos($string, '.');
if($isint === FALSE){
$bn = $number / $ic;
if($this->isPrime($bn)){
$answer = $bn;
$ic = $number;
}else if($this->isPrime($ic)){
$answer = $ic;
}
}
}
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;
}
$answer = 6,857
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
