Wednesday, February 27, 2019

An interesting problem in Number Theory and Probability



 

Was just talking to a friend who is a Math prof, when she posed me this question: What is the last digit of the number 7 raised to 85?

 

When you start working that out, 7 raised to 1, ends in 7; raised to 2 ends in 9; raised to 3 ends in 3; and raised to 4 ends in 1; and then the cycle repeats. Therefore for any positive integer n, 7 raised to n ends in 7 when n mod 4 is 1; ends in 9 when n mod 4 is 2; ends in 3 when n mod 4 is 3; and ends in 1 when n mod 4 is 1.

 

In case of 7 raised to 85, 85 modulo 4, is 1. Hence 7 raised to 85 ends in 7.

 

Which is fine, but one needs to generalise that for all numbers.

 

Hence one can ask the question:   for a number a^n   , where both a and n are natural numbers , what is the probability that a^n   ends in 1,2,3,4,5,6,7,8,9, and 0, respectively.

 

Let us first look at each a separately:

 

(a)   For a = any number ending in 1 (the probability of which in a random sample is 0.1) : a^n   will end in 1 all the time (100%)

 

(b)  For a = any number ending in 2 (the probability of which in a random sample is 0.1) : a^n   will end in 2,4,8, and 6 , 25% of the time each.

 

( c ) For a = any number ending in 3 : a^n   will end in 3,9,7 and 1, 25% of the time each

 

(d) For a = any number ending in 4: a^n   will end in 4 and 6, 50% of the time each

 

(e) For a = any number ending in 5: a^n   will end in 5 hundred percent of the time

 

(f) For a = any number ending in 6: a^n   will end in 6 hundred percent of the time

 

(g) For a = any number ending in 7: a^n   will end in 7,9,3 and 1, 25% of the time each

 

(h) For a = any number ending in 8: a^n   will end in 8,4,2 and 6, 25% of the time each

 

(i)             For a = any number ending in 9: a^n   will end in 9 and 1, 50% of the time each

 

(j) For a = any number ending in 0 (not being 0, since we defined a and n as Natural Numbers): a^n   will end in 0 hundred percent of the time.

 

Now computing each of the probabilities of a^n   ending in :

 

1: 0.1 x 1 (a) plus 0.1 x 0.25 (c ) plus 0.1 x 0.25 (g) plus 0.1 x 0.5 ( i) = 0.1 x 2 = 20 percent

 

Applying the same method, we get the probability that a^n   ends in

1: is 20 percent

2: is 5 percent

3: is 5 percent

4: is 10 percent

5: is 10 percent

6: is 20 percent

7: is 5 percent

8: is 5 percent

9: is 10 percent

0: is 10 percent

 

I also ran a simulation in excel with a sample size of 1000 randomly generated a^n   . The resulting frequency table closely matches my result, hence I think my answer should be correct.

 

The frequency table generated through a Monte Carlo:

 

endnos.

frequency

my answer

0

10.241%

10%

1

19.177%

20%

2

4.618%

5%

3

4.719%

5%

4

11.044%

10%

5

10.341%

10%

6

20.181%

20%

7

4.217%

5%

8

5.422%

5%

9

10.040%

10%

 

 

Your comments are welcome.

 

No comments: