4
This commit is contained in:
parent
a6d766562c
commit
87526928ec
22
euler4.php
Normal file
22
euler4.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/*
|
||||
* Gnieark's anwser to euler problem 4
|
||||
* https://projecteuler.net/problem=4
|
||||
*/
|
||||
|
||||
$pal=0;
|
||||
for($i=1000;$i>99;$i--){
|
||||
for($j=1000;$j>99;$j--){
|
||||
$prod=$i*$j;
|
||||
if ((isPalindrome($prod)) && ($prod>$pal)) {
|
||||
$pal=$prod;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $pal;
|
||||
|
||||
function isPalindrome($number){
|
||||
if(strrev(strval($number)) == strval($number)){
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user