A Challange
Posted: Wed Jun 16, 2004 11:10 pm
Hi;
I have been given a challange that I am trying to complete using PHP Code. The challenge is:
Am I correct in my thinking of the code or am I missing something?
Any help will be appreciated.
Thanks;
Moe
I have been given a challange that I am trying to complete using PHP Code. The challenge is:
I have started with the following code:Find a six digit number that gives its digits reversed when multiplied by an integer between 2 and 9 inclusive. For example, if the original number was 654321 and the chosen integer was 8, then 654321 x 8 should equal 123456 if it was the magic number (which of course it doesnt). There are two (2) solutions.
Code: Select all
<?php
for ($i = 100000;$i<=999999; $i++) { // Sets out 6 digit numbers
for ($m = 2; $m<=9; $m++){ //set out multiplier integer
$a = $i * $m; // multiplies 6 digit number by multiplier
$r = strrev($a); //reversed answer
}
if ($r = $i) { //checks if reversed answer = 6 digit number
echo $a;
echo "<br>";
}
}
?>Any help will be appreciated.
Thanks;
Moe