GenerateRandomSearch

Modular Arithmetic Question Generator

Three tasks that build on each other. Reducing a number modulo something is division with only the remainder kept. Raising to a power is the same thing done carefully — computing the power outright would give an enormous number, so you reduce at every step, and repeated squaring turns an exponent of forty into about six multiplications. Inverses are the one with a precondition: a value has an inverse modulo m only when the two share no factor, and 6 has none modulo 9 for exactly that reason.

What this generator does

Generates one of three tasks against a prime or small composite modulus: reduce a number, raise a value to a power modulo the modulus, or find a modular inverse. Inverse questions only ever use values coprime to the modulus, because otherwise there is no answer.

How to use this tool

  1. Choose which of the three tasks you want.
  2. Work it out, watching the range the answer must fall in.
  3. Reveal the answer and the working.
  4. Seed the question to reproduce it later.

Understanding the controls

Task
Reduce a number, raise to a power, or find an inverse. The three are a natural progression, and only the last one can fail to have an answer.
Seed
Reproduces the same values and modulus from a word you choose.
Show the answer
Reveals the result along with the division, the squaring chain or the coprimality argument.

Common use cases

  • Practice for a number theory or cryptography course
  • Showing why repeated squaring is necessary rather than merely clever
  • Drilling the coprimality condition for inverses to exist
  • Connecting clock arithmetic to the general rule
  • Setting the same questions to a group from a seed

How this generator works

Powers use repeated squaring with a reduction after every multiplication, so intermediate values stay small enough to hold exactly. Inverse questions redraw the value until it is coprime to the modulus. The check recomputes each answer and, for inverses, multiplies it back and requires exactly one.

Randomness and fairness

The values, exponents and modulus are random; the answers are computed and verified. Seeded questions reproduce and are therefore explicitly not cryptographically secure — and nothing here should be used to generate cryptographic material. Unseeded, the browser's cryptographically secure generator supplies the draws.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Moduli are small — under 25 — so the numbers stay hand-checkable rather than realistic.
  • The inverse is found by search rather than by the extended Euclidean algorithm, which is the method a course would teach.
  • Negative values are not used, so the sign convention for remainders is described but not exercised.
  • The Chinese remainder theorem and systems of congruences are not covered.
  • Questions are not stored between visits; seed one you want again.

Privacy and your data

Every value and answer is computed in your browser. Nothing about the question or your seed is transmitted or stored.