1001Ferramentas
Calculators

Modular Exponentiation Calculator

Calculate modular exponentiation (b to the power e, modulo m) fast with the square-and-multiply method. Essential in RSA cryptography and number theory.

bᵉ mod m

Modular exponentiation: algorithm and example

Modular exponentiation gives you a^b mod n while never letting the monstrous intermediate a^b appear at all. The usual way to do this is exponentiation by squaring, also called binary exponentiation. You walk through the bits of b, square the running base mod n at each step, and fold that into the result whenever the current bit happens to be 1. The whole thing costs O(log b) multiplications.

Take 3^200 mod 50 as an example. You begin with 3² = 9, then 3⁴ = 81 mod 50 = 31, then 3⁸ = 31² mod 50 = 11, continuing that way and combining the squares whose bit positions add up to 200. When n = p is prime, Fermat's little theorem cuts the work down: a^(p−1) ≡ 1 (mod p) as long as gcd(a, p) = 1.

Applications

  • RSA signing and encryption, where c = m^e mod n and e is usually 65537.
  • Diffie–Hellman key exchange, where each side computes g^x mod p.
  • ECDSA and the other elliptic-curve protocols that lean on fast modular powers.
  • The Miller–Rabin primality test, plus cryptographic hashes that fold modular powers into the compression step.

FAQ

Why not just compute a^b and take mod n at the end? Because a^b can run to billions of digits. Reducing mod n on every step is what keeps the numbers from blowing up.

What if b is negative? Find the modular inverse of a first, then raise that to |b|.

Is binary exponentiation constant-time? Not on its own. A naive implementation branches on the bits of b, and that timing can leak the exponent. To close the side channel, cryptographic libraries reach for the Montgomery ladder or fixed-window variants.

Related Tools

📉

Elastic Shortening Loss

Calculate the prestress loss from concrete elastic shortening, Δσ = (E_s/E_c)·σ_c, from the steel modulus E_s (MPa), the concrete modulus E_c (MPa) and the concrete stress at the tendon level σ_c (MPa). It is one of the IMMEDIATE prestress losses (at transfer, not over time): when the tendon is tensioned and anchored, it compresses the concrete, and the concrete, being compressed, SHORTENS elastically. Since the tendon is bonded or anchored in this shortened concrete, it shortens too — and shortening, it LOSES part of its tension. The loss is proportional to the modular ratio αe = E_s/E_c (typically 6-8, since steel is much stiffer than concrete) times the concrete compression stress at the tendon level. In members with SEVERAL tendons prestressed sequentially, each new tendon compresses and shortens the concrete, causing loss in already-anchored tendons — so the average loss is often taken as half the value (the first tendons lose more than the last). This is one of the losses to subtract from the initial force to get the effective prestressing force. Enter the steel and concrete moduli and the concrete stress.

xⁿ

Power Calculator

Calculate the power aⁿ of any base and exponent, including negatives and decimals. Shows the result in scientific notation when necessary.

Concrete Creep Loss

Calculate the prestress loss from concrete creep, Δσ = φ·(E_s/E_c)·σ_cg, from the creep coefficient φ (dimensionless), the modular ratio E_s/E_c and the concrete stress at the tendon level from permanent loads σ_cg (MPa). Creep is the SLOW, growing deformation concrete undergoes under CONSTANT load over time: besides the immediate elastic shortening when compressed, concrete keeps shortening gradually for months and years, reaching a total deformation 2-3 times the initial elastic one. In a prestressed member, the concrete is PERMANENTLY compressed by the prestress, so it creeps (shortens slowly), and the bonded tendon shortens with it, LOSING tension — the largest time-dependent loss in many cases. The loss is the creep coefficient φ (typically 1.5-3.5, a function of humidity, loading age, member dimensions) times the equivalent elastic loss (modular ratio × concrete stress). With shrinkage and relaxation, creep defines the total time-dependent prestress loss. Estimating these losses well is crucial: underestimating leaves the member with less prestress than intended (cracking risk); overestimating wastes steel. Enter the creep coefficient, the modular ratio and the concrete stress.

🔁

Modular Inverse Calculator

Calculate the modular inverse a⁻¹ mod m with the extended Euclidean algorithm. The inverse exists when a and m are coprime. Key in cryptography and number theory.

🧩

Typographic Modular Scale

Computes typographic modular scale using Fibonacci or golden ratio from body text.

🕉️

Vedic Sign

Estimates Vedic moon sign (Rashi) from birth date approximation.

The results provided by this tool are for general informational and educational purposes only and do not constitute professional, financial, medical, legal, tax or accounting advice. Always confirm important decisions with a qualified professional and official sources.