# Number Theory Calculator - Modular Power, Inverse, CRT and Euler’s Totient

> Free online number theory tools: modular exponentiation, modular inverses and Bézout coefficients, the Chinese remainder theorem and Euler's totient φ(n).

- URL: https://qilingtools.com/en/math/number-theory
- Category: Math Tools (https://qilingtools.com/en/math)
- Tags: [Math](https://qilingtools.com/en/tags/math), [Algorithms](https://qilingtools.com/en/tags/algorithm)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

Four everyday number theory calculations in one place: modular exponentiation (the core step in RSA and hashing), modular inverses with the Bézout identity, the Chinese remainder theorem for systems of congruences, and Euler’s totient with divisor statistics. Everything runs on big integers, so there is no rounding error.

## How to use

1. Pick what to compute: modular power, modular inverse, Chinese remainder or Euler’s totient
2. Enter the integers (for the Chinese remainder theorem, one “remainder modulus” pair per line)
3. Read the result — inverses come with a check and congruences with the general solution

## Features

- Fast exponentiation a^b mod m in O(log b) multiplications, with the actual count shown
- Extended Euclidean algorithm giving the gcd and the Bézout identity ax + my = gcd, plus a verification of the inverse
- Chinese remainder theorem for any number of congruences, checking compatibility when the moduli are not coprime
- Euler’s totient φ(n) alongside the prime factorisation, divisor count d(n) and divisor sum σ(n)
- BigInt arithmetic throughout, so results are exact well beyond 2^53

## FAQ

### Why is 7^222 mod 13 instant?

It uses fast exponentiation: the exponent is written in binary and the base is squared repeatedly from the top bit down, multiplying whenever the bit is 1. With 222 taking only 8 bits, a dozen or so multiplications finish the job instead of 222 of them.

### What is a modular inverse and when does it not exist?

It is the x with a·x ≡ 1 (mod m). It exists only when gcd(a, m) = 1, that is when a and m are coprime; otherwise the tool says so plainly.

### What kind of problem does the Chinese remainder theorem solve?

Classic remainder puzzles: “leaves 2 when divided by 3, 3 when divided by 5, 2 when divided by 7”. Enter one “remainder modulus” pair per line and you get the smallest non-negative solution plus the general form x = x₀ + Mk.

### Can I use moduli that are not coprime?

Yes. A solution may then fail to exist, so each pair is checked: the difference of the remainders must be divisible by their gcd. If it is not, the system is reported as having no solution; if it is, the answer is given modulo the least common multiple.

### What is Euler’s totient used for?

φ(n) counts the integers below n that are coprime to n. It underpins Euler’s theorem a^φ(n) ≡ 1 (mod n) and the choice of exponents in RSA. For a prime p, φ(p) = p − 1.

## Related tools

- [Graphing Calculator](https://qilingtools.com/en/math/graph): Free online function graphing calculator: type sin(x), x^2 or 1/x and see the curve at once, with several functions, parametric and polar curves, PNG export.
- [Scientific Calculator](https://qilingtools.com/en/math/calculator): Free online scientific calculator: type 2*(3+4)^2, sin(pi/6) or log(8,2) and see the answer as you type, with degrees or radians and a history list.
- [Equation Solver](https://qilingtools.com/en/math/equation): Free online equation solver: enter coefficients for linear, quadratic (with discriminant, vertex and complex roots) and cubic equations, plus 2×2 systems.
- [Fraction Calculator](https://qilingtools.com/en/math/fraction): Free online fraction calculator: add, subtract, multiply and divide fractions with automatic reduction, plus fraction ↔ decimal with repeating digits.
- [Percentage Calculator](https://qilingtools.com/en/math/percentage): Free online percentage calculator: X% of Y, X as a percent of Y, increase and decrease, a value after a percentage change and the original behind it.
- [Prime Factorization](https://qilingtools.com/en/math/prime): Free online prime factorization: factor an integer with exponents, list every divisor and their sum, test primality with neighbouring primes, or list a range.
- [GCD and LCM](https://qilingtools.com/en/math/gcd-lcm): Free online GCD and LCM calculator: works with two or more integers, says whether they are coprime, shows each prime factorization and every Euclidean step.
- [Statistics Calculator](https://qilingtools.com/en/math/statistics): Free online statistics calculator: paste a data set for the mean, median, mode, range, quartiles, variance, standard deviation, standard error and outliers.
