Choosing randomly two integer numbers from 10 to 1,000,000 inclusive,
What are the chances they will be represented:
a. each by two distinct digits, albeit different
for each one of the numbers e.g. 322 and 78778
b.exactly the same two, like 3334 and 433344
or
c. distinct couples, sharing one digit like 5558 and 88338
(In reply to
simulation by Charlie)
The simulation program had a bug; the corrected program:
clearvars,clc
typea=0; typeb=0; typec=0;
for trial=1:100000000
n1=char(string(randi(999991)+9));
if length(unique(n1))==2
n2=char(string(randi(999991)+9));
if length(unique(n2))==2 % correction in bold
switch length(unique([n1 n2]))
case 2
typeb=typeb+1;
case 3
typec=typec+1;
case 4
typea=typea+1;
end
end
end
end
typea
typeb
typec
typea/trial
typeb/trial
typec/trial
trial/typea
trial/typeb
trial/typec
and output:
typea =
1349
typeb =
48
typec =
796
a ans =
1.349e-05
b ans =
4.8e-07
c ans =
7.96e-06
reciprocal
a ans =
74128.9844329133
b ans =
2083333.33333333
c ans =
125628.140703518
|
Posted by Charlie
on 2023-07-14 11:48:10 |