Lesson Using the little Fermat's theorem to solve a problem on modular arithmetic

Algebra ->  Divisibility and Prime Numbers -> Lesson Using the little Fermat's theorem to solve a problem on modular arithmetic      Log On


   


This Lesson (Using the little Fermat's theorem to solve a problem on modular arithmetic) was created by by ikleyn(52906) About Me : View Source, Show
About ikleyn:

Using the little Fermat's theorem to solve a problem on modular arithmetic


Problem 1

For a certain positive integer  n,  the number   n%5E6873  leaves a remainder of  3  when divided by  131.
What remainder does  n  leave when divided by  131?

Solution

We are given that the remainder

    n%5E6873 mod 131  is 3.


Notice that 131 is a prime number and 6873 = 113 mod 130.


    Now apply the little Fermat's theorem.

    It says that for fixed integer "n", where n is relatively prime to 131,  the sequence  
    k --> n%5Ek mod 131 is periodical (= cyclic) over integer values k = 1, 2, 3, . . . 
     with the period of 130.



It tells us that n%5E6873 = n%5E113 = 3 mod 131.  
Based on this information, we should find {n mod 131}.



    Let me repeat it again:

        Using the little Fermat's theorem, we deduced 
        from the given info that  n%5E113 = 3 mod 131.
        Having it, we want to find  {n mod 131}.



Take  n%5E113 = 3 mod 131 and square it. You will get  n%5E%282%2A113%29 = 3%5E2 mod 131.

Take  n%5E113 = 3 mod 131 and cube   it. You will get  n%5E%283%2A113%29 = 3%5E3 mod 131.

. . . and so on . . . 

Take  n%5E113 = 3 mod 131 and raise to degree m. You will get  n%5E%28m%2A113%29 = 3%5Em mod 131.



The idea is to find a degree m such that m*113 = 1 mod 130.

Then, due to little Fermat's theorem (again) we will have n = 3%5Em mod 131 and will solve our problem this way.



    Thus, our task is to find m, which is 
    the Modular Multiplicative Inverse to 113 modulo 130.



Fortunately, in the Internet there are calculators for it,
that solve this intermediate task.  See these links

    Modular Multiplicative Inverse Calculator
    https://planetcalc.com/3311/

    Inverse Modulo Calculator
    https://www.omnicalculator.com/math/inverse-modulo


The Modular Multiplicative Inverse to 113 modulo 130 is 107 modulo 130.


Now the only thing to complete the solution is to find 3%5E107 mod 131.



For it, I created Excel spreadsheet below.

The working formula in my spreadsheet is  a%5Bn%2B1%5D = Mod%283%2Aa%5Bn%5D%2C+131%29,  a%5B1%5D = 3.


  T  A  B  L  E 

k               3%5Ek mod 131
------------------------------------
1		  3
2		  9
3		 27
4		 81
5		112
6		 74
7		 91
8		 11
9		 33
10		 99
11		 35
12		105
13		 53
14		 28
15		 84
16		121
17		101
18		 41
19		123
20		107
21		 59
22		 46
23		  7
24		 21
25		 63
26		 58
27		 43
28		129
29		125
30		113
31		 77
32		100
33		 38
34		114
35		 80
36		109
37		 65
38		 64
39		 61
40		 52
41		 25
42		 75
43		 94
44		 20
45		 60
46		 49
47		 16
48		 48
49		 13
50		 39
51		117
52		 89
53		  5
54		 15
55		 45
56		  4
57		 12
58		 36
59		108
60		 62
61		 55
62		 34
63		102
64		 44
65		  1
66		  3
67		  9
68		 27
69		 81
70		112
71		 74
72		 91
73		 11
74		 33
75		 99
76		 35
77		105
78		 53
79		 28
80		 84
81		121
82		101
83		 41
84		123
85		107
86		 59
87		 46
88		  7
89		 21
90		 63
91		 58
92		 43
93		129
94		125
95		113
96		 77
97		100
98		 38
99		114
100		 80
101		109
102		 65
103		 64
104		 61
105		 52
106		 25
107		 75    <---=== 



The ANSWER to the problem's question is 75.

In other words, n leaves the remainder 75 when is divided by 131.

Couple of post-solution notes:

    (1)  Finding the Modular Multiplicative Inverse to 61 modulo 131 is a technical issue.

         I used and referred to online calculators with the only goal do not distract 
         a reader from the mainstream idea of the solution.


    (2)  The method making calculations in the spreadsheet is to avoid overflowing (= loosing the precision)
         when using direct formula for  (3%5Em mod 131).

My other lessons in this site on miscellaneous problems on divisibility of integer numbers are
    - Light flashes on a Christmas tree and a Least Common Multiple
    - The number that leaves a remainder 1 when divided by 2, by 3, by 4, by 5 and so on until 9
    - The number which gives remainder 4 when divided by 7, remainder 5 when divided by 8 and remainder 6 when divided by 9
    - Introductory problems on divisibility of integer numbers
    - Finding Greatest Common Divisor of integer numbers
    - Relatively prime numbers help to solve the problem
    - Solving equations in integer numbers
    - Quadratic polynomial with odd integer coefficients can not have a rational root
    - Proving an equation has no integer solutions
    - Composite number of the form (4n+3) must have a prime divisor of the form (4n+3)
    - Problems on divisors of a given number
    - How many three-digit numbers are multiples of both 5 and 7?
    - How many 3-digit numbers are not divisible by 2; not divisible by 3; not divisible by either 2 or 3
    - How many integer numbers in the range 1-300 are divisible by at least one of the integers 4, 6 and 15 ?
    - Find the remainder of division
    - Why 3^n + 7^n - 2 is divisible by 8 for all positive integer n ?
    - What is the last digit of the number a^n ?
    - Find the last three digits of these numbers
    - Find the last two digits of the number 3^123 + 7^123 + 9^123
    - Find the last two digits of (1! + 2! + 3! + ... + 2024!)^2024
    - Find n-th term of a sequence
    - Solving Diophantine equations
    - How many integers of the form n^2 + 18n + 13 are perfect squares
    - Miscellaneous problems on divisibility numbers
    - Find the sum of digits of integer numbers
    - Two-digit numbers with digit "9"
    - Find a triangle with integer side lengths and integer area
    - Math circle level problem on the hundred-handed monster Briareus
    - Math Circle level problem on lockers and divisors of integer numbers
    - Nice entertainment problems related to divisibility properties
    - Solving problems on modular arithmetic
    - OVERVIEW of miscellaneous solved problems on divisibility of integer numbers



This lesson has been accessed 1128 times.