The method of successive squaring described in the text allows you to compute ak (mod m) quite efficiently, but it does involve creating a table of powers of a modulo m.
(a) Show that the following algorithm will also compute the value of ak (mod m). It is a more efficient way to do successive squaring, well-suited for implementation on a computer.
(1) Set b = 1
(2) Loop while k ≥ 1
(3) If k is odd, set b = a • b (mod m)
(4) Set a = a2 (mod m).
(5) Set k = k/2 (round down if k is odd)
(6) End of Loop
(7) Return the value of b (which equals ak (mod m))
(b) Implement the above algorithm on a computer using the computer language of your choice.
(c) Use your program to compute the following quantities:
(i) 21000 (mod 2379)
(ii) 5671234 (mod 4321)
(iii) 47258008 (mod 1315171)
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.