Modular Exponentiation Calculator

Compute b^e mod m fast with exact big numbers and see whether Fermat's little theorem applies.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Step 1: Open Modular Exponentiation Calculator and add your input

    Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.

  2. 2
    Step 2: What Modular Exponentiation Calculator does

    Compute b^e mod m fast with exact big numbers and see whether Fermat's little theorem applies.

  3. 3
    Step 3: Read the result and compare

    The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.

  4. 4
    Step 4: Copy or save it

    Copy the result or download it. For an important decision, confirm it with the official source or an adviser.

About this tool

Enter a base b, an exponent e and a modulus m. The calculator returns b^e mod m using square-and-multiply, so huge exponents are instant, plus the number of bits in e and a Fermat check.

Square-and-multiply

The exponent is read in binary. For each bit the running value is squared, and multiplied by b when the bit is 1, always reduced mod m. This needs only about log₂(e) steps.

Fermat check

If m is prime and does not divide b, then b^(m−1) ≡ 1 (mod m). The tool reports whether b^e ≡ 1 with gcd(b, m) = 1; with e = m − 1 a failure proves m is not prime. The exponent must not be negative and may have up to 300 digits.

Worked example

7^560 mod 561 = 1 even though 561 = 3 × 11 × 17 is composite, a Carmichael number.

Tips for best results

Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.

Quick facts

Embed this calculator on your site

Copy this code to show the calculator on your own page. A link back to shobfree.com is included.

Frequently asked questions

How big can the exponent be?

Hundreds of digits.

What is a Carmichael number?

A composite number that passes the Fermat test for all coprime bases.

What if e is 0?

The result is 1.

Can the base be negative?

Yes; the result is in 0 … m − 1.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages