Home > College Algebra calculators > Fast modular exponentiation example

6. Fast modular exponentiation example ( Enter your problem )
  1. Example-1 : 3^302 mod 5
  2. Example-2 : 19^24 mod 21
  3. Example-3 : 7^106 mod 143
  4. Example-4 : 27^400 mod 619
Other related methods
  1. Chinese Remainder Theorem
  2. Extended Euclidean Algorithm
  3. Euclid's Algorithm
  4. Modular multiplicative inverse
  5. Modulo
  6. Fast modular exponentiation

5. Modulo
(Previous method)
2. Example-2 : 19^24 mod 21
(Next example)

1. Example-1 : 3^302 mod 5





1. 3^302 mod 5

Solution:
Fast Modular Exponentiation
3^302" mod "5

Comparing with A^B" mod "C

We get A=3,B=302,C=5

Step 1: Divide B into powers of 2 by writing it in binary

302=100101110 in binary

302=2^1+2^2+2^3+2^5+2^8

302=2+4+8+32+256

3^302" mod "5=3^((2+4+8+32+256))" mod "5

3^302" mod "5=(3^2*3^4*3^8*3^32*3^256)" mod "5


Step 2: Calculate mod C of the powers of two <= B

3^1" mod "5=3" mod "5=3

3^2" mod "5=(3^1*3^1)" mod "5=(3^1" mod "5*3^1" mod "5)" mod "5=(3*3)" mod "5=9" mod "5=4

3^4" mod "5=(3^2*3^2)" mod "5=(3^2" mod "5*3^2" mod "5)" mod "5=(4*4)" mod "5=16" mod "5=1

3^8" mod "5=(3^4*3^4)" mod "5=(3^4" mod "5*3^4" mod "5)" mod "5=(1*1)" mod "5=1" mod "5=1

3^16" mod "5=(3^8*3^8)" mod "5=(3^8" mod "5*3^8" mod "5)" mod "5=(1*1)" mod "5=1" mod "5=1

3^32" mod "5=(3^16*3^16)" mod "5=(3^16" mod "5*3^16" mod "5)" mod "5=(1*1)" mod "5=1" mod "5=1

3^64" mod "5=(3^32*3^32)" mod "5=(3^32" mod "5*3^32" mod "5)" mod "5=(1*1)" mod "5=1" mod "5=1

3^128" mod "5=(3^64*3^64)" mod "5=(3^64" mod "5*3^64" mod "5)" mod "5=(1*1)" mod "5=1" mod "5=1

3^256" mod "5=(3^128*3^128)" mod "5=(3^128" mod "5*3^128" mod "5)" mod "5=(1*1)" mod "5=1" mod "5=1


Step 3: Use modular multiplication properties to combine the calculated mod C values

3^302" mod "5

=(3^2*3^4*3^8*3^32*3^256)" mod "5

=(3^2" mod "5*3^4" mod "5*3^8" mod "5*3^32" mod "5*3^256" mod "5)" mod "5

=(4*1*1*1*1)" mod "5

=4" mod "5

=4

:.3^302" mod "5=4


This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then Submit Here



5. Modulo
(Previous method)
2. Example-2 : 19^24 mod 21
(Next example)





Share this solution or page with your friends.
 
 
Copyright © 2025. All rights reserved. Terms, Privacy
 
 

.