Number Theory Calculator — Primes, GCD/LCM, Modular Arithmetic & More
Number Theory Calculator
Explore prime numbers, factorization, greatest common divisors, modular arithmetic, and more.
All calculations are performed locally in your browser — your input is never uploaded.
Mode:
Prime Number Checker
Enter a number and click "Check"
Tip: Uses deterministic Miller-Rabin for numbers up to 264.
Click "Next Prime" or "Prev Prime" to find nearby primes.
Prime Factorization
Enter a number and click "Factorize"
Tip: Supports integers up to 1015. Factor tree decomposition with prime-exponent representation.
GCD & LCM Calculator
Enter numbers and click GCD, LCM, or Both
Tip: Input 2 or more integers separated by commas. GCD uses the Euclidean algorithm; LCM is computed as |a*b|/(a,b).
Modular Arithmetic
Enter a, b, m and click an operation
Tip: Modular exponentiation uses fast exponentiation (square-and-multiply).
Modular inverse only exists when a and m are coprime.
Divisors & Divisor Functions
Enter a number and click "Compute"
Tip: Lists all positive divisors, divisor count d(n), sum of divisors σ(n),
and proper divisors. Supports numbers up to 1012.
Totient & Arithmetic Functions
Enter a number and click "Compute"
Tip: Computes Euler's totient φ(n), Möbius function μ(n),
σ(n), d(n), and related arithmetic functions.
Primes and congruences
A prime has exactly two divisors, 1 and itself; every integer greater than 1 factors into primes in exactly one way (the fundamental theorem of arithmetic). Congruence a ≡ b (mod n) means n divides a−b — arithmetic on a clock face, where 10 + 5 ≡ 3 (mod 12), and the foundation of GCD, LCM and modular exponentiation.
Multiplying two big primes is instant, but recovering them from the product is computationally brutal — that one-way asymmetry is what RSA encryption is built on, and why φ(n) of a 2048-bit modulus is not public.