How to use the number theory calculator
- Choose a tool: GCD, LCM, prime test, prime factorization, divisibility, factorial or modulo.
- Enter the whole number or numbers it asks for.
- Read the exact result; large results are shown in full, not rounded.
What each tool does
GCD is the largest number dividing both inputs; LCM is the smallest number both divide into, and LCM(a, b) = |a × b| ÷ GCD(a, b). Prime factorization writes a number as a product of primes, such as 84 = 2² × 3 × 7.
A prime test checks divisors up to the square root. Modulo is the remainder after division, and n! multiplies every whole number from 1 to n.
Worked examples
GCD and LCM
gcd(84, 30) = 6 and lcm(84, 30) = 420; 6 × 420 = 84 × 30.
Modulo
17 mod 5 = 2, because 17 = 3 × 5 + 2.
Frequently asked questions
How do I find the LCM of two numbers?
Divide their product by their greatest common divisor. For 4 and 6: 24 ÷ 2 = 12.
What is the difference between GCD and GCF?
None. Greatest common divisor, greatest common factor and highest common factor are the same thing.