MathComplete - Number Theory Lab

Is this a prime?

A fast Fermat-based check, plus the math story behind it.

Quick Check

Enter any integer (very large values are supported). We use Fermat tests to decide if it is probably prime.

Waiting for input
We will show the result and the reasoning.
Algorithm Steps (short)
  1. Eliminate obvious composites: n < 2, even numbers, or divisible by small primes.
  2. Run Fermat tests for several bases a: check a^(n-1) mod n = 1.
  3. If any test fails, n is composite; if all pass, n is probably prime.

Algorithm Behind It

The explanation is written in Markdown and rendered here. You can edit the content files directly.

正在载入教学内容...