Hello,
I'm having trouble getting my code to work. It seems that my function isPalindrome works correctly when I just test it out on some particular products of 3-digit integers, but when I use it in my full program, it fails to do its job.
Here's my code:
Thanks for any help!
P.S. Yes, this is for one of the early Project Euler problems..
I'm having trouble getting my code to work. It seems that my function isPalindrome works correctly when I just test it out on some particular products of 3-digit integers, but when I use it in my full program, it fails to do its job.
Here's my code:
Code:
for ($j = "100"; $j <= "110"; $j += 1){
for($i = "100"; $i <= $j; $i += 1){
if(isPalindrome($i*$j)){
print STDOUT ($i*$j)." Is a product of two three-digit integers and a palindrome.";
}
}
}
sub isPalindrome {
my($Qstring) = @_;
for($i = 0; $i <= length($Qstring)-1; $i++){
if(substr($Qstring,$i,1) == substr($Qstring,length($Qstring)-1-$i,1)){}
else{return 0;}
}
return 1;
}
P.S. Yes, this is for one of the early Project Euler problems..
Comment