This question is related to this Stack Overlow post. I tried following R code to find a 4 digit number divided by a 3 digit number (all unique digits) so that result equals 9:
ss = sample(0:9, 7)
while(TRUE){
print(ss)
if(ss[4]+10*ss[3]+100*ss[2]+1000*ss[1]/(ss[7]+10*ss[6]+100*ss[5]) == 9){ break }
ss = sample(0:9, 7)
}
print("found:")
ss
Program runs for a long time but no such number is found. I will appreciate any information on this. My apologies if this is a trivial issue.
EDIT: This is a programming error with '()'. On correcting it many such numbers are found:
Found: 3708 and 412
Found: 1863 and 207
Found: 6831 and 759
Found: 4689 and 521
Found: 7461 and 829
Found: 8523 and 947
Found: 7569 and 841
Found: 4761 and 529
Found: 5472 and 608
Found: 7506 and 834
Found: 8127 and 903
Found: 4761 and 529
Found: 8253 and 917
Found: 8163 and 907
Found: 3681 and 409
Found: 6381 and 709
Found: 6318 and 702
Found: 6408 and 712
Found: 5427 and 603
Found: 8127 and 903
Found: 3681 and 409
Found: 3672 and 408
Found: 8613 and 957
Found: 3762 and 418
...
Thanks for your help.
Instead of looking at $10^7$ possible pairs of two numbers, you can loop over $10^3$ (actually, $900$) three-digit numbers. Multiply each by $9$, and check whether the digits of the product are distinct. To extract the digits, you can divide the product by $10$, take the remainder, and repeat this four times.