Ad Space
Not sure? Click here.
  • Prime Factorization — use this to break a number down into the primes that multiply together to make it.
  • Primality Test — use this to check whether a single number is prime or composite.
  • Modular Exponentiation — use this to compute base ^ exponent mod n (base raised to a power, then reduced by a modulus) efficiently, the operation at the core of RSA and Diffie-Hellman cryptography.
Prime Factorization
Result

Prime Number Reference

CategoryExamples
First few primes2, 3, 5, 7, 11, 13, 17, 19
Well-known primes23, 29, 31, 41, 97
Common in cryptography65537 (Fermat F4)
Twin primes(11, 13), (17, 19), (29, 31)
Mersenne primes (2ⁿ − 1)3, 7, 31, 127, 8191
Sophie Germain primes2, 3, 5, 11, 23, 83
Common false positives561, 1105, 1729 (composite — used to test primality checkers)
Result

base ^ exponent mod n

Ad Space

Number Theory Explained

Number theory studies whole numbers and the relationships between them — this calculator covers three foundational tools: breaking a number into its prime building blocks, testing primality, and efficiently computing huge modular powers.

Prime factorization writes a number as a product of primes: n=p1a1×p2a2××pkakn = p_1^{a_1} \times p_2^{a_2} \times \cdots \times p_k^{a_k}

n: the number being factored.

p1, p2, …, pk: the distinct prime factors of n.

a1, a2, …, ak: the exponent (how many times) each prime appears in the factorization.

Modular exponentiation computes bemodnb^e \bmod n efficiently using square-and-multiply, repeatedly squaring the base and reducing modulo nn at every step rather than computing the full power first.

b: the base.

e: the exponent.

n: the modulus.

Worked Example: Fermat's Little Theorem Check

Using the modular exponentiation mode's defaults — base 7, exponent 560, modulus 561 — the result comes out to 1. This is a deliberately chosen example: 561 is the smallest Carmichael number, a composite number that still satisfies Fermat's little theorem-like behavior for many bases, which is exactly why naive Fermat primality testing can be fooled by numbers like it (real primality tests use more robust methods, like Miller-Rabin, specifically to catch these edge cases).

Why Prime Factorization Underlies Modern Cryptography

RSA encryption, one of the most widely deployed public-key cryptographic systems, relies directly on the practical difficulty of factoring the product of two large prime numbers, even though multiplying those two primes together is trivial. This asymmetry — easy to multiply, hard to un-multiply — is the entire security foundation of RSA, and it's why finding faster factorization algorithms (or building a sufficiently powerful quantum computer, which could factor efficiently via Shor's algorithm) remains a subject of serious ongoing research.

A Brief History of Number Theory

Euclid's Elements (circa 300 BCE) contains some of the earliest recorded results in number theory, including a proof that there are infinitely many primes. Pierre de Fermat's 17th-century work on number properties (including his famously unproven "last theorem," not resolved until Andrew Wiles's 1994 proof) established number theory as a serious mathematical discipline. The field's practical importance exploded in the late 20th century once RSA (1977) and related cryptographic systems built modern digital security directly on top of number-theoretic hardness assumptions.

Common Number Theory Mistakes

Assuming a number is prime just because it passes a quick divisibility check by a few small primes is a common error — genuine primality testing must rule out every possible factor up to the square root (or use a rigorous probabilistic test for very large numbers). Confusing the security of RSA-style cryptography with the impossibility of factoring (it's merely impractically slow with current classical methods, not mathematically impossible) is another frequent misconception. Forgetting to reduce modulo n at each intermediate step in a hand-calculation of modular exponentiation — instead computing the full power first — is a third common mistake, and one this calculator's algorithm specifically avoids.

Number Theory Terms You Should Know

Prime Number — a whole number greater than 1 with no divisors other than 1 and itself.

Prime Factorization — expressing a number as a product of its prime factors.

Modular Arithmetic — arithmetic performed with numbers that "wrap around" after reaching a modulus.

Carmichael Number — a composite number that can fool simple Fermat-based primality tests for many bases.

This calculator uses trial division for factorization and primality testing, which is exact but can be slow for very large numbers with large prime factors; it uses BigInt arithmetic for exact large-integer modular exponentiation.

Frequently Asked Questions

Why is prime factorization considered hard for large numbers?

For small numbers, checking every possible divisor up to the square root (what this calculator does) is fast. But as numbers grow into the hundreds of digits, the number of possible divisors to check grows so explosively that even the fastest known classical algorithms and supercomputers would take longer than the age of the universe — this difficulty is exactly what keeps RSA encryption secure.

Why do we need fast modular exponentiation instead of just computing the power directly?

Computing a huge power like 7^1000 directly would produce a number with hundreds of digits before you could even take the remainder — computationally wasteful and, in many programming languages, impossible without special big-number support. Fast modular exponentiation (square-and-multiply) instead reduces modulo n after every squaring step, keeping every intermediate number the same size as the modulus, which is dramatically faster and exactly how real cryptographic systems compute these values.

Where is modular exponentiation actually used?

It's the computational core of RSA encryption and Diffie-Hellman key exchange, two of the most widely used cryptographic systems on the internet — both rely on computing base^exponent mod n efficiently for enormous numbers, while relying on the fact that reversing the process (discrete logarithm or factoring) is computationally infeasible.

Ad Space