27 lines
432 B
PHP
27 lines
432 B
PHP
<?php
|
|
|
|
error_reporting(E_ALL);
|
|
ini_set("display_errors", 1);
|
|
|
|
$number = 0;
|
|
|
|
while ($number < 500000) {
|
|
$number++;
|
|
|
|
if (!isSquareNumber($number) or !crossSumIs43($number)) {
|
|
continue;
|
|
}
|
|
|
|
echo "FOUND: $number\n";
|
|
}
|
|
|
|
function isSquareNumber($number): bool
|
|
{
|
|
return ($sqrt = sqrt($number)) == floor($sqrt);
|
|
}
|
|
|
|
function crossSumIs43($number): bool
|
|
{
|
|
return array_sum(str_split(strval($number))) === 43;
|
|
}
|