3 ms·
For those who have Mathematica and want to experiment with this, here's a quick function to generate the data: f[n_, base_] := Module[ {m, d, dp
by ms013 11y ago
For those who have Mathematica and want to experiment with this, here's a quick function to generate the data:
f[n_, base_] :=
Module[
{m, d, dpairs},
d = Table[Last[IntegerDigits[Prime[i], base]], {i, 1, n}];
dpairs = Table[{d[[i]], d[[i + 1]]}, {i, 1, Length[d] - 1}];
Map[#[[1]] -> #[[2]] &, Tally[dpairs]]
]
For the first n primes in a given base, it returns the mapping {i,j}->count for the all pairings of digit i followed by digit j. E.g., for the first million base 5 primes
{2, 3} -> 68596
{3, 0} -> 1,
{0, 2} -> 1,
{2, 1} -> 64230
{1, 3} -> 77475
{3, 2} -> 72827
{2, 4} -> 77586
{4, 3} -> 64371
{3, 4} -> 79358
{4, 1} -> 84596
{1, 2} -> 79453
{4, 2} -> 58130
{4, 4} -> 42843
{1, 1} -> 42853
{3, 3} -> 39668
{2, 2} -> 39603
{1, 4} -> 50153
{3, 1} -> 58255
- Steuard 11y agoIt took me embarrassingly long to notice that Last[IntegerDigits[x,base]] is just Mod[x,base] (which ought to be faster). I guess the author wanted to avoid discussing modular arithmetic in an article for general audiences?