4

Suppose you're given a natural number with $N$ digits, randomly chosen except that none of the digits are $0$. Now shuffle its digits to obtain a new $N$-digit number. What is the probability (as $N\rightarrow\infty$, say) that the new number and the old one are relatively prime?

mjqxxxx
  • 43,344
  • 1
    why no 0's as digits? – mathworker21 Dec 15 '18 at 05:48
  • also, when you say "to obtain a new $N$-digit number" are you excluding permutations that result in the same number being obtained? if so, that makes the problem much uglier – mathworker21 Dec 15 '18 at 05:52
  • @mathworker21: the chance the permutation matches is $\frac 1{N!}$, which is tiny and goes to $0$ as $N \to \infty$. I presume the prohibition on zeros is to make sure neither permutation has leading zeros. I don't think that really matters. – Ross Millikan Dec 15 '18 at 06:01
  • @RossMillikan the $\frac{1}{N!}$ can be added many times... – mathworker21 Dec 15 '18 at 06:03
  • The restriction on zeroes is to avoid worrying about leading zeroes. I think the question would not be substantially harder or easier if zeroes were allowed. And the "new" part doesn't matter; the probability of getting the same number back certainly goes to zero as $N\rightarrow\infty$. – mjqxxxx Dec 15 '18 at 07:06

1 Answers1

6

We know that the chance two numbers are coprime is $\frac 6{\pi^2}$ as shown in this question.

The exclusion of $0$ changes the chances that the numbers are divisible by $2$ and $5$. With all digits included the chance one number is divisible by $2$ is $\frac 12$ and the chance both are is $\frac 14$. Now the chance a number is even is $\frac 49$ and the chance both are is $\frac {16}{81}$. Similarly the chance both are multiples of $5$ is now $\frac 1{81}$ instead of $\frac 1{25}$.

The scrambling of the digits introduces an important correlation because if one of them has a factor $3$ so does the other. The chance two numbers both have a factor $3$ is $\frac 19$ so in our case the factor $\frac 89$ that they do not both have a factor $3$ is replaced by a factor $\frac 23$.

The probability that they are not both multiples of any of $2,3,5$ now is $(1-\frac {16}{81})(1-\frac 13)(1-\frac 1{81})=\frac {10400}{19683}$ instead of $(1-\frac 14)(1-\frac 19)(1-\frac 1{25})=\frac {16}{25}.$ We would expect the probability they are coprime to be $\frac 6{\pi^2}\cdot \frac {25}{16} \cdot \frac {10400}{19683}\approx 0.502$ per Alpha.

I can't prove that there are no changes for the probability for other primes, but one way to motivate it for primes with rather less than $N$ digits is to think about each digit contributing the the remainder on division by the prime. It adds in one of nine remainders that are reasonably scattered through the residues.

Ross Millikan
  • 383,099
  • This is a comment, not an answer. – mathworker21 Dec 15 '18 at 06:00
  • 1
    @mathworker21: No... it is a (partial) answer... not a comment. – David G. Stork Dec 15 '18 at 06:19
  • @DavidG.Stork No. The question asked what is the probability. Ross said what we would expect the probability to be. That is a comment, not an answer. – mathworker21 Dec 15 '18 at 06:23
  • I like the direction of this answer -- correct the independent-numbers probability to account for invariants -- but I don't think it's exactly right, because simulation seems to give a slightly higher probability. – mjqxxxx Dec 15 '18 at 07:11
  • @mjqxxxx: I realized the mix of digits changed the chances for $2,5$ as well and have updated. – Ross Millikan Dec 15 '18 at 14:55
  • @RossMillikan let us know what answer you get next! – mathworker21 Dec 15 '18 at 17:30
  • Very interesting approach, but I wonder if $11$ is the next term that causes trouble, needing a (very minor) correction? Shuffling the digits is equivalent to addition/subtraction of terms of the form $a \times 99...9$ where $a$ is a single digit. All the $99...9$s are divisible by $3$ which is why $3$ needs a major correction, but about half of the $99...9$s (all those with even number of digits) are divisible by $11$. In fact I seem to recall every prime $p$ divides some $99...9$. My gut feel is the correction is still very small...? – antkam Dec 17 '18 at 19:25
  • 1
    @antkam: yes, every prime divides a number of the form $10^k-1$ but that does not mean a correction is needed. For $11$, for example, there are $81$ different pairs of digits available when $0$s are excluded. There are $9$ pairs with sum $10 \bmod 11$ and $7$ pairs with each other remainder. As you couple those with other pairs the differences wash out quickly, so if $N$ is large the numbers will be equally distributed. All we need is that very close to $\frac 1{11}$ have divisor $11$. The same logic works for any prime much smaller than $N$ digits. – Ross Millikan Dec 17 '18 at 22:59
  • yeah i believe you're right. the funky thing with $11$ is that every $a \times 99...9 \pmod{11} = 0$ or $9a$, but because the shuffling is random about half the digits contribute $9a$ and for large $N$ this should still lead to ${1 \over 11}$ chance of being a multiple of $11$. – antkam Dec 18 '18 at 13:54