Builidng Better Solutions For Web Development Recent WorkHow We Work
ProjectEuler.net
P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8 | P9 | P10 | P22

Project Euler.net Answers

Problem 4

Solved on 2/26/2008

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

Product1:913
Product2:993
Answer: 906,609

$answer = 0;
for($oc = 999; $oc>1; $oc--){
for($ic = 999; $ic>1; $ic--){
if($this->isPal($ic*$oc)){
if($ic*$oc > $answer){
$answer = $ic*$oc;
$p1 = $ic;
$p2 = $oc;
}
}
}
}
public function isPal($val){
$rev = strrev($val);
if(strlen($val) % 2 == 0){
$length = strlen($val)/2;
return (substr($val,0,$length) == substr($rev,0,$length));
}else{
$length = (strlen($val)-1)/2;
return (substr($val,0,$length) == substr($rev,0,$length));
}
}

Latest News
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.
Quote Of The Day
"The greatest challenge to any thinker is stating the problem in a way that will allow a solution."
- Bertrand Russell