Worked solution: 7^200 mod 13
Step-by-step working for this modular arithmetic problem, produced and checked by the solver.
Modular arithmetic Answer checked
Answer
- Use repeated squaring, reducing mod 13 at every stepNever work out the huge power first: reduce after each multiplication.
- Binary of the powerMultiply in the squares that match each 1 bit.
- Result
- Check: multiply 200 times, reducing each time
Change the numbers and solve your own
The method in brief
- a mod n: divide and keep the remainder. Negative numbers still give a result from 0 to n - 1.
- For big powers, square repeatedly and reduce mod n at every step.
- The inverse of a mod n exists only when gcd(a, n) = 1. Find it with the extended Euclidean algorithm.
- Solve ax ≡ b (mod n): there are solutions only if gcd(a, n) divides b.
Full guide: Mod, powers mod n, inverses and congruences.