FOR a = 1 TO 5
used(a) = 1
FOR b = a + 1 TO 6
used(b) = 1
FOR c = b + 1 TO 7
used(c) = 1
FOR d = c + 1 TO 8
used(d) = 1
FOR e = d + 1 TO 9
used(e) = 1
FOR f = 1 TO 9
IF used(f) = 0 THEN
used(f) = 1
abcdef = 100000 * a + 10000 * b + 1000 * c + 100 * d + 10 * e + f
FOR g = 1 TO 9
IF used(g) = 0 THEN
used(g) = 1
FOR h = 1 TO 9
IF used(h) = 0 THEN
used(h) = 1
FOR i = 1 TO 9
IF used(i) = 0 THEN
used(i) = 1
ghi = 100 * g + 10 * h + i
IF abcdef MOD ghi = 0 THEN
PRINT abcdef, ghi, abcdef / ghi
END IF
used(i) = 0
END IF
NEXT i
used(h) = 0
END IF
NEXT h
used(g) = 0
END IF
NEXT g
used(f) = 0
END IF
NEXT
used(e) = 0
NEXT
used(d) = 0
NEXT
used(c) = 0
NEXT
used(b) = 0
NEXT
used(a) = 0
NEXT
produces
ABCDEF GHI quotient
125673 489 257
136782 459 298
147896 532 278
156784 239 656
156792 834 188
156894 237 662
246789 153 1613
256794 381 674
257891 463 557
345681 279 1239
345897 621 557
567891 243 2337
567892 134 4238
Of these, it can be noted that only 246789 has all the digits ABCDEF in order, rather than just the ABCDE required by the puzzle.
|
Posted by Charlie
on 2012-06-09 10:51:25 |