Math / CALCULATOR

Fermat Congruence for a Prime

Fermat Congruence for a Prime with a worked example and explicitly bounded inputs.

Runs on your deviceUpdates as you typeFormula & example ↓
01

Your inputs

Adjust the values to explore a different result.

Enter integer a.
Enter prime p.

Formula

For prime p and a not divisible by p, a^(p−1) mod p=1.
  • Use the units shown beside each field.
  • Results update automatically whenever you change an input.
  • Displayed values use up to four decimal places, or scientific notation for very small or large numbers. Calculations use standard floating-point arithmetic; exact integer and fraction tools identify their own precision rules.
  • p is independently checked by trial division; the theorem is not used as a primality test.

Example Calculation

Example inputs
  • Integer a: 2
  • Prime p: 7

Integer a = 2; Prime p = 7. Primary result: 1.

Frequently asked questions

How do I use this calculator?

Enter integer a, prime p. The result updates automatically. Use Reset to restore the example values.

What method does it use?

For prime p and a not divisible by p, a^(p−1) mod p=1.. p is independently checked by trial division; the theorem is not used as a primality test.

Why might a rounded result differ?

The calculation keeps full numeric precision internally, then rounds the displayed result. Rounding intermediate steps by hand can produce a slightly different answer.

Are my inputs saved online?

No. This calculator processes your inputs in your browser. A recently used list stores only calculator names on this device, not your entered values.

Check the assumptions and units before using this result. Read about calculation methods.