Input a base, exponent, and modulus to get the result using the fast exponentiation algorithm.
Modular exponentiation involves finding the result of raising a base to an exponent and then computing the remainder when divided by a modulus. It is represented as:
\( a^b \bmod c \)
Here: \( a \) is the base, \( b \) is the exponent, \( c \) is the modulus.
This operation is widely used in cryptography, computer science, and number theory to efficiently compute large powers while keeping results manageable.
Calculating \( a^b \bmod c \) directly by finding \( a^b \) and then taking the modulus is computationally impractical for large values of \( b \). Instead, the fast exponentiation algorithm or modular exponentiation algorithm is used. Steps of the Fast Exponentiation Algorithm:
Solution:
Binary representation of 3: \( 3_{10} = 11_2 \).
Initialize: result = 1, base = 5, modulus = 13.
Process binary digits (right to left):
Result: \(5^3 \bmod 13 = 8\).
Solution:
Binary representation of 4: \( 4_{10} = 100_2 \).
Initialize: result = 1, base = 7, modulus = 10.
Process binary digits (right to left):
Result: \(7^4 \bmod 10 = 1\).
Solution:
Binary representation of 10: \( 10_{10} = 1010_2 \).
Initialize: result = 1, base = 3, modulus = 7.
Process binary digits (right to left):
Result: \(3^{10} \bmod 7 = 4\).