Guest User

Untitled

a guest
Dec 10th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. <?php
  2.  
  3. function isPalindrome($text) {
  4.    
  5.     $text = (string)$text;
  6.    
  7.     // This is the long and stupid way of doing this
  8.     $backwards = '';
  9.     for ($i = strlen($text) - 1; $i >= 0 ; $i--) {
  10.         $backwards .= $text{$i};
  11.     }
  12.    
  13.     return $text == $backwards;
  14.    
  15. }
  16.  
  17. $max = 0;
  18. for ($i = 100; $i < 1000; $i++) {
  19.     for ($j = 100; $j < 1000; $j++) {
  20.         $num = $i * $j;
  21.         $max = isPalindrome($num) && $num > $max ? $num : $max;
  22.     }
  23. }
  24. echo $max;
Add Comment
Please, Sign In to add comment