Determine the probability that for a positive base ten integer X drawn at random between 1 and 100 inclusively, the number 10X is expressible as the product of precisely two positive integers, neither of which contains the digit zero.
The probability is 1/10 as there are 10 values of x that work: 1, 2, 3, 4, 5, 6, 7, 9, 18 and 33.
The program logic depends on the fact that neither factor chosen can have both 2 and 5 as factor within itself, and so they must be 2^x and 5^x.
list
10 for X=1 to 100
15 Y=10^X
20 Dvr=2^X
30 Q=5^X
40 S=cutspc(str(Dvr)+str(Q))
50 if instr(S,"0")=0 then
60 :print X;Y;Dvr;Q
70 :Ct=Ct+1
90 next X
100 print Ct
OK
run
x 10^x factors
1 10 2 5
2 100 4 25
3 1000 8 125
4 10000 16 625
5 100000 32 3125
6 1000000 64 15625
7 10000000 128 78125
9 1000000000 512 1953125
18 1000000000000000000 262144 3814697265625
33 1000000000000000000000000000000000 8589934592 116415321826934814453125
10 (count of values)
Increasing the limit beyond x=100, to the limit of UBASIC, shows no other possible values of x through 1549, so one can hypothesize that there are no more such values ever, but that's just that--a hypothesis:
list
10 for X=1 to 2100
15 Y=10^X
20 Dvr=2^X
30 Q=5^X
40 S1=cutspc(str(Dvr)):S2=str(Q)
50 if instr(S1,"0")=0 and instr(S2,"0")=0 then
60 :print X;Y;Dvr;Q
70 :Ct=Ct+1
90 next X
100 print Ct
OK
run
1 10 2 5
2 100 4 25
3 1000 8 125
4 10000 16 625
5 100000 32 3125
6 1000000 64 15625
7 10000000 128 78125
9 1000000000 512 1953125
18 1000000000000000000 262144 3814697265625
33 1000000000000000000000000000000000 8589934592 116415321826934814453125
Overflow in 40
?x
1550
|
Posted by Charlie
on 2009-10-06 12:17:28 |