Skip to main content
Skip to calculator
Advertisement

Last updated: July 31, 2026

Fermat's Little Theorem Calculator

Helpful
Not helpful
Save as image
Share
Embed
Cite
Write feedback

Formula

Compute remainder=a^(p−1) mod p; theorem holds when p is prime, a mod p ≠ 0, and remainder=1

Where:

  • a=a
  • p=p
Fermat's Little TheoremThe identity a raised to the power p minus 1, taken modulo p, equals 1 for prime p.aᵖ⁻¹ ≡ 1 (mod p)Valid whenever p is prime and a is not divisible by p
Fermat's Little Theorem underpins primality tests and modular arithmetic used in cryptography.

Worked Examples

a=2, p=7

Worked scenario for this calculator.

  1. 1Enter the input values.
  2. 2Apply the calculator formula.
  3. 3Read the computed outputs.
Final Answer: remainder=1, holds=yes

a=14, p=7

Worked scenario for this calculator.

  1. 1Enter the input values.
  2. 2Apply the calculator formula.
  3. 3Read the computed outputs.
Final Answer: remainder=0, holds=no

a=5, p=11

Worked scenario for this calculator.

  1. 1Enter the input values.
  2. 2Apply the calculator formula.
  3. 3Read the computed outputs.
Final Answer: remainder=1, holds=yes

Introduction

Verify Fermat’s Little Theorem for integer a and prime p using modular exponentiation.

Formula and Method

Fermat's Little Theorem Calculator uses: Compute remainder=a^(p−1) mod p; theorem holds when p is prime, a mod p ≠ 0, and remainder=1

  • Enter the required inputs.

  • Apply the mathematical relationship.

  • Compute each output key directly.

  • Round numeric results for stable display.

Input Fields

Use these input keys exactly as shown in the calculator form.

  1. 1

    a: a

  2. 2

    p: p

Output Fields

These are the outputs returned by the calculation.ts implementation.

  1. 1

    remainder: remainder

  2. 2

    holds: holds

Validation Rules

Validation prevents undefined math states and invalid numeric input.

  • a and p must be integers.

  • p must be prime.

  • Errors are returned with safe default outputs when validation fails.

How to Use This Calculator

Follow a simple input → calculate → interpret workflow.

  • Fill in all required fields.

  • Click calculate.

  • Check the primary output first.

  • Use examples to verify manual work.

Practical Uses

This calculator supports both learning and quick technical checks.

  • Homework and exam prep.

  • Classroom demonstrations.

  • Engineering/science sanity checks.

  • Rapid what-if analysis with new inputs.

FAQs

What does the Fermat's Little Theorem Calculator compute?

Verify Fermat’s Little Theorem for integer a and prime p using modular exponentiation.

Which inputs are required?

Required inputs are all fields marked required in the form. Optional fields can be left blank.

How are invalid inputs handled?

The calculator validates numeric rules first and returns an error message with safe default outputs when rules are violated.

Are results rounded?

Numeric outputs are rounded to about 6 decimal places for stable and readable display.

Can I use decimals?

Yes, decimals are supported unless an input requires integers (such as index, count, or theorem parameters).

Can I use this to verify manual solutions?

Yes. Use the formula section and worked examples to cross-check hand calculations quickly.