What is the first 12-digit sequence in the duodecimal expansion of pi that contains each digit exactly once?
I grabbing a big (1 M digit) Pi text file, and
used the easy "on the fly" method of conversion...
3.
0.1415926 × 12 = 0.6991112 + 1
0.6991112 × 12 = 0.3893344 + 8
0.3893344 × 12 = 0.6720128 + 4
0.6720128 × 12 = 0.0641536 + 8
which just involved multiplying the huge numbers by 12.
I wondered how many digits I would need to look through, so I computed
1/Prob(of success) = 12^11/11! since the likelihood of the next digit not
being a repeat is 11/12 x 10/12 ... 1/12. This gave 18613. So, I decided to
look through the 1st 30,000 digits. The solution happily showed up towards the end.
The program is here. First, as a check, I list the 1st 5 and last 5 digits of Pi
out of a million in base 10. I also list the first few digits of Pi base 12 = 3.1848093b9...
as a check. The program runs in a minute.
lord@rabbit 13324 % p12
14159
62541
Pi(base 12) = 3 . 1 8 4 8 0 9 4 9 3 11 9 1 8 6 6 4 5 7 3 10
1000 out of 30000
2000 out of 30000
4000 out of 30000
5000 out of 30000
.
.
.
26000 out of 30000
27000 out of 30000
28000 out of 30000
digit value
index base 12
---------------
28641 1
28642 11
28643 2
28644 5
28645 0
28646 7
28647 3
28648 6
28649 9
28650 10
28651 8
28652 4
lord@rabbit 13324 % prob (inverted)
18613.9238
Edited on November 6, 2023, 10:36 am