FOR a = 1 TO 9
FOR b = 1 TO 9
ab = a * 10 + b
FOR c = 1 TO 9
ac = a * 10 + c
bc = b * 10 + c
FOR d = 1 TO 9
ad = a * 10 + d
bd = b * 10 + d
cd = c * 10 + d
abcd = ab * 100 + cd
IF abcd MOD ab = 0 THEN
IF abcd MOD ac = 0 THEN
IF abcd MOD ad = 0 THEN
IF abcd MOD bd = 0 THEN
IF abcd MOD cd = 0 THEN
IF abcd MOD bc <> 0 THEN
PRINT abcd
hitCt = hitCt + 1
END IF
END IF
END IF
END IF
END IF
END IF
ct = ct + 1
NEXT
NEXT
NEXT
NEXT
PRINT hitCt; "/"; ct; "="; hitCt / ct
finds
1995
2184
3774
and
3 / 6561 = 4.572474E04
as there are 9^4 = 6561 numbers tested of which only 3 satisfy the criteria, and 3/6561 = 1/2187 ~= .0004572474.

Posted by Charlie
on 20101019 19:07:05 