Maths & numbers

Shortest addition chain calculator for integer exponents

An addition chain describes how to build an integer power while reusing powers already computed.

Your numbers

Integer 1–128. Exact search fails closed if its state cap is reached.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

An addition chain describes how to build an integer power while reusing powers already computed. Each new exponent is the sum of two earlier exponents, corresponding to one multiplication. This calculator searches all eligible pairs rather than restricting each step to the previous largest exponent plus one earlier value. It reports a minimum only after every smaller feasible chain length has been exhausted.

THE FORMULAa₀=1<a₁<…<a_r=n, with each a_j equal to a sum of two earlier entries. Minimize r.

A worked example

For exponent 15, one shortest chain is 1,2,3,5,10,15. It represents x²=x×x, x³=x²×x, x⁵=x³×x², x¹⁰=x⁵×x⁵ and x¹⁵=x¹⁰×x⁵: five multiplications. The binary square-and-multiply construction can use six for this target. The calculator can return another chain of length five; equal optimal lengths do not imply identical intermediate powers.

Good to know

Targets are integers from 1 through 128. The search counts multiplications for an unrestricted increasing addition chain, not additions, divisions, memory transfers or multiplication timings. Only one shortest chain is returned. A two-million-state cap produces an error rather than relabeling an unproven candidate as optimal. The target one has zero multiplications and chain [1].

Doubling gives a lower bound, not usually the answer

The largest obtainable exponent can at most double after one additional multiplication. Starting from one, r multiplications therefore cannot reach more than 2^r. This gives the lower bound ceil(log₂ n). A binary construction supplies an upper bound: repeatedly square while scanning the target’s binary digits and multiply by x when a one bit requires it.

When the bounds differ, the search checks chain lengths in increasing order. Within a fixed length it considers sums of every pair of earlier entries, retaining only strictly increasing candidates no larger than the target. If even repeated doubling from a candidate cannot reach the target in the remaining steps, that branch cannot succeed and is safely pruned.

The chain to fifteen reuses the exponents three and two to make five123510155 = 3 + 2; 10 = 5 + 515 = 10 + 5 → 5 multiplications
The five multiplications follow exponents 1,2,3,5,10,15. Every exponent adds two earlier ones: 2=1+1,3=2+1,5=3+2,10=5+5,15=10+5. This is an optimal-length chain, not a unique chain.

The Modular exponentiation calculator computes a numeric modular power. This page optimizes the abstract multiplication schedule for reaching an exponent.

Do not mistake a restricted search for an optimality proof

A star chain requires the next exponent to use the immediately previous largest exponent. Although many familiar short chains have that property, an unrestricted addition-chain search must allow two earlier entries that do not include the latest one. Restricting the candidate family without saying so would prove optimality for the wrong problem.

This engine forms every pair sum from the complete existing prefix. Duplicate sums are merged because they produce the same next exponent and available prefix. Pair order does not distinguish a chain, but the table still supplies one valid multiplication identity for each new entry. A returned length is proven by exhausting shorter depths, not by comparing only with binary exponentiation.

Optimal multiplication count is not a timing forecast

An addition chain treats each multiplication as one abstract operation, including squaring. Actual large-integer implementations can use different costs for squaring and general multiplication. Memory pressure, modular reduction and parallel execution can also change which chain is fastest. The result therefore describes a mathematical count, not a hardware benchmark.

For modular exponentiation, the same exponent schedule may be used while reducing every product modulo m, but this page deliberately does not compute that residue or apply group-order shortcuts. The existing modular exponentiation calculator performs the related numeric evaluation. A resource-cap failure here means a minimum was not established in the allowed work, not that no chain exists.

A few questions, answered

Why can my shortest chain differ from the example?

Several optimal chains may have the same length. The displayed pair identities certify legality; the depth search certifies the minimum number of multiplications.

What does a search-limit error mean?

No proven minimum is returned within the allowed state budget. It is not a proof that the requested exponent is unreachable.

Find your calculator

Start typing to explore the library.