Determine the probability that for a positive integer N chosen at random between 1000 and 9999 inclusively, the sum of the products of pairs of digits in N is equal to the sum of products of triplets of its digits.
The numbers that satisfy the criteria are:
number pairwise products products of triples
ab ac ad bc bd cd bcd acd abd abc
1000 0 0 0 0 0 0 0 0 0 0
1123 1 2 3 2 3 6 6 6 3 2
1132 1 3 2 3 2 6 6 6 2 3
1213 2 1 3 2 6 3 6 3 6 2
1231 2 3 1 6 2 3 6 3 2 6
1312 3 1 2 3 6 2 6 2 6 3
1321 3 2 1 6 3 2 6 2 3 6
2000 0 0 0 0 0 0 0 0 0 0
2036 0 6 12 0 0 18 0 36 0 0
2044 0 8 8 0 0 16 0 32 0 0
2063 0 12 6 0 0 18 0 36 0 0
2113 2 2 6 1 3 3 3 6 6 2
2131 2 6 2 3 1 3 3 6 2 6
2306 6 0 12 0 18 0 0 0 36 0
2311 6 2 2 3 3 1 3 2 6 6
2360 6 12 0 18 0 0 0 0 0 36
2404 8 0 8 0 16 0 0 0 32 0
2440 8 8 0 16 0 0 0 0 0 32
2603 12 0 6 0 18 0 0 0 36 0
2630 12 6 0 18 0 0 0 0 0 36
3000 0 0 0 0 0 0 0 0 0 0
3026 0 6 18 0 0 12 0 36 0 0
3033 0 9 9 0 0 9 0 27 0 0
3062 0 18 6 0 0 12 0 36 0 0
3112 3 3 6 1 2 2 2 6 6 3
3121 3 6 3 2 1 2 2 6 3 6
3206 6 0 18 0 12 0 0 0 36 0
3211 6 3 3 2 2 1 2 3 6 6
3260 6 18 0 12 0 0 0 0 0 36
3303 9 0 9 0 9 0 0 0 27 0
3330 9 9 0 9 0 0 0 0 0 27
3602 18 0 6 0 12 0 0 0 36 0
3620 18 6 0 12 0 0 0 0 0 36
4000 0 0 0 0 0 0 0 0 0 0
4024 0 8 16 0 0 8 0 32 0 0
4042 0 16 8 0 0 8 0 32 0 0
4204 8 0 16 0 8 0 0 0 32 0
4240 8 16 0 8 0 0 0 0 0 32
4402 16 0 8 0 8 0 0 0 32 0
4420 16 8 0 8 0 0 0 0 0 32
5000 0 0 0 0 0 0 0 0 0 0
6000 0 0 0 0 0 0 0 0 0 0
6023 0 12 18 0 0 6 0 36 0 0
6032 0 18 12 0 0 6 0 36 0 0
6203 12 0 18 0 6 0 0 0 36 0
6230 12 18 0 6 0 0 0 0 0 36
6302 18 0 12 0 6 0 0 0 36 0
6320 18 12 0 6 0 0 0 0 0 36
7000 0 0 0 0 0 0 0 0 0 0
8000 0 0 0 0 0 0 0 0 0 0
9000 0 0 0 0 0 0 0 0 0 0
51
So 51 out of the (9999 - 999) = 9000 numbers satisfy the criterion.
51/9000 = 17/3000 ~= 0.00566667 or 1/176.47058824
DEFDBL A-Z
FOR a = 1 TO 9
FOR b = 0 TO 9
pairtot1 = a * b: tripprod1 = a * b
FOR c = 0 TO 9
pairtot2 = pairtot1 + a * c + b * c
triptot1 = tripprod1 * c: tripprod2 = a * c: tripprod3 = b * c
FOR d = 0 TO 9
pairtot3 = pairtot2 + a * d + b * d + c * d
triptot2 = triptot1 + tripprod2 * d + tripprod3 * d + tripprod1 * d
IF triptot2 = pairtot3 THEN
PRINT LTRIM$(STR$(a)); LTRIM$(STR$(b)); LTRIM$(STR$(c)); LTRIM$(STR$(d)),
PRINT a * b; a * c; a * d; b * c; b * d; c * d, b * c * d; a * c * d; a * b * d; a * b * c
ct = ct + 1
END IF
NEXT
NEXT
NEXT
NEXT
PRINT ct
|
Posted by Charlie
on 2009-11-08 16:42:29 |