Probability of a big number that is composed of two special numbers to be multiple of 19

93 Views Asked by At

A big number, which is 117179 digits in length, was constructed by concatenation of only two special numbers, which are 40 and 8 (both 40 and 8 must be used). There are around 62870 of any of those two special numbers can be used at most. I would like to know what is the probability of observing a number less than 117179 digits to be multiple of 19 with the above mentioned constraints? The probability should also consider the reverse concatenation too.

The use case is as follows: Assume that someone encoded a book with such coding to embed a signature in it to check its integrity. One letter corresponds to 40 and the other corresponds to 8. When you concatenate the appearance of those letters with their correspondence numbers then you observe the big resulting number is multiple of 19. Then the question is what is the probability of observing such number by chance alone?

I was asked to clarify in the comments. So here is an example: like if there is letter x in the text we replace it with 40 and if there is y we replace it with 8 in the book and concatenate only these numbers over all the book (excluding anything else, so the order matters). then we have a number like 4084040408840..........840408404040

1

There are 1 best solutions below

4
On BEST ANSWER

I'm not sure how to give an exact answer, but the following argument suggests the answer is close to $\frac{1}{19}$. There are 8 possibilities for a string of 3 digits: 088,084,040,888,884,840,408,404. I haven't worked out exactly what proportion of the time the patterns 408 and 840 come up, but I expect they each come up at least $\frac{1}{20}$ of the time (i.e. $\frac{1}{10}$ of the time in total). That means there are at least roughly 4000 instances of either 408 or 840 in a 120,000-digit number, treating the number as a sequence of non-overlapping three-digit strings.

Now, $840-408\equiv 14\pmod{19}$, and $1000\equiv 12 \pmod{19}$. 19 is prime, so repeatedly multiplying by 12 hits all 18 possible nonzero remainders mod 19, before returning to the starting point. In roughly 1/18 of the instances of 408/840 (i.e. roughly 200 instances), changing from 408 to 840 would increase the remainder by 1, or changing from 840 to 408 would decrease the remainder by 1. Now, we can treat the number of instances of 408/840 in place values where increasing from 408 to 840 would increase the remainder by 1 as a $Binomial(200,0.5)$ random variable. Similarly, the places where going from 840 to 408 would increase the remainder by 1, or going from 408 to 840 would decrease the remainder by 1, give us another $Binomial(200,0.5)$ random variable, whose sum is a $Binomial(400,0.5)$ random variable. You can check that of the possible outcomes of a $Binomial(400,0.5)$ random variable, the probability of each remainder when you divide by 19 is roughly constant, with variation in only the 4th decimal place. Thus, considering only those patterns is enough to show the probability is roughly $\frac{1}{19}$, to 3 decimal places.