How to resolve the algorithm Modular exponentiation step by step in the Maxima programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Modular exponentiation step by step in the Maxima programming language

Table of Contents

Problem Statement

Find the last   40   decimal digits of

a

b

{\displaystyle a^{b}}

,   where

A computer is too slow to find the entire value of

a

b

{\displaystyle a^{b}}

. Instead, the program must use a fast algorithm for modular exponentiation:

a

b

mod

m

{\displaystyle a^{b}\mod m}

. The algorithm must work for any integers

a , b , m

{\displaystyle a,b,m}

,     where

b ≥ 0

{\displaystyle b\geq 0}

and

m

0

{\displaystyle m>0}

.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Modular exponentiation step by step in the Maxima programming language

Source code in the maxima programming language

a: 2988348162058574136915891421498819466320163312926952423791023078876139$
b: 2351399303373464486466122544523690094744975233415544072992656881240319$
power_mod(a, b, 10^40);
/* 1527229998585248450016808958343740453059 */


  

You may also check:How to resolve the algorithm Palindrome detection step by step in the F# programming language
You may also check:How to resolve the algorithm Iterated digits squaring step by step in the Clojure programming language
You may also check:How to resolve the algorithm Roman numerals/Encode step by step in the Clojure programming language
You may also check:How to resolve the algorithm Number reversal game step by step in the Euphoria programming language
You may also check:How to resolve the algorithm Strip control codes and extended characters from a string step by step in the Scala programming language