More progress

This commit is contained in:
2024-07-23 09:13:29 +00:00
parent 3903a79785
commit 6b8afd49b9
9 changed files with 223 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
//Find a three-digit number such that when the digits are reversed and subtracted from the original number, the result is a multiple of 9.
function numreverse($number) {
$numberStr = (string)$number;
$numberStr = strrev($numberStr);
return (int)$numberStr;
}
$i = 100;
$good = 0;
$bad = 0;
while($i <=999) {
$num = $i - numreverse($i);
if($num != 0 && $num % 9 == 0) {
echo("\nFound $i");
$good++;
} else {
echo("\nNo $i");
$bad++;
}
$i++;
}
echo "\nGood: $good Bad: $bad";