Skip to content

Instantly share code, notes, and snippets.

@gavinsykes
Created April 29, 2020 21:26
Show Gist options
  • Save gavinsykes/e7242433355d774e4929f7db15a55bb6 to your computer and use it in GitHub Desktop.
Save gavinsykes/e7242433355d774e4929f7db15a55bb6 to your computer and use it in GitHub Desktop.
<?php
require_once '../php_functions.php';
function euler_4($n) {
if (($n < 1) || !is_int($n)) {
return undefined;
}
$result = 0
for ($i = 1; $i <= 10**$n; $i++) {
for ($j = 1; $j <= 10**$n; $j++) {
$prod = $i*$j;
if (is_palindrome($prod) && $prod > $result) {
$result = $prod;
}
}
}
return $result;
}
$v = $_REQUEST['val'];
echo euler_4($v);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment