I have iput of reminder. I want to get divisive integer
Example:
15%7 = 1
14%7 = 0
9%7 = 2
Here input 1, 0, 2 and output 15, 14 and 9
For input 5 what will be the output. Surely it may be 13. But how to get it by php coding? Suppose we don’t know the divider 7
My try
<?php
function findNumberWithUnknownDivisor($remainder) {
// Starting with an initial guess for the divisor
$maxPossibleDivisor = 100; // Arbitrary large value to test possible divisors
for ($divisor = 1; $divisor <= $maxPossibleDivisor; $divisor++) {
for ($i = $remainder; $i < $divisor * 10; $i += $divisor) {
if ($i % $divisor == $remainder) {
return $i;
}
}
}
return null; // If no match is found
}
$remainder = 5;
$result = findNumberWithUnknownDivisor($remainder);
echo "A number with remainder $remainder is: $result";
?>