Determine the probability that for a positive integer N drawn at random between 3 and 202 inclusively, the sum of the digits in the base ten representation of 2011 (base N) is a perfect square.
N digits sum sq root
3 2 2 0 2 1 1 1 9 3
8 3 7 3 3 16 4
10 2 0 1 1 4 2
20 5 0 11 16 4
22 4 3 9 16 4
26 2 25 9 36 6
60 33 31 64 8
80 25 11 36 6
92 21 79 100 10
106 18 103 121 11
110 18 31 49 7
127 15 106 121 11
134 15 1 16 4
136 14 107 121 11
148 13 87 100 10
178 11 53 64 8
190 10 111 121 11
194 10 71 81 9
There are 18 bases out of the 200, so the probability is 9%.
DEFDBL A-Z
CLS
FOR n = 3 TO 202
digs = 0
num = 2011
tot = 0
DO
d = num MOD n
tot = tot + d
num = num \ n
dig(digs) = d
digs = digs + 1
LOOP UNTIL num = 0
sr = INT(SQR(tot) + .5)
IF sr * sr = tot THEN
PRINT n,
FOR i = digs - 1 TO 0 STEP -1
PRINT dig(i);
NEXT
PRINT TAB(39); tot; TAB(45); sr
ct = ct + 1
END IF
NEXT n
PRINT ct
|
Posted by Charlie
on 2011-10-29 14:12:01 |