Coprime Number Generator
Two numbers are coprime when their only common factor is one — and neither of them has to be prime for that. 8 and 9 are coprime; 8 and 12 are not. The property matters because it decides when a modular inverse exists and when the Chinese remainder theorem applies. Each set here comes with a deliberate counterexample and with Euler's totient of a number, counted one value at a time rather than looked up.
What this generator does
Draws pairs and keeps the ones whose greatest common divisor is one, holding back the first failure as a contrast. It also counts how many numbers up to a chosen base are coprime to it, which is Euler's totient of that base.
How to use this tool
- Choose how large the numbers may be and how many pairs you want.
- Check each pair yourself with Euclid's algorithm.
- Read the counterexample to see a pair that fails and why.
- Compare the totient count against your own.
Understanding the controls
- Largest number
- How big the numbers may get, from 10 up to 200. Wider ranges make coprime pairs more common, not less.
- How many pairs
- Between 1 and 20 pairs, all distinct — ten is enough to see how common coprimality actually is.
- Seed
- Any word reproduces the same pairs and the same totient example, so a worksheet can be reissued.
Common use cases
- Test values for anything that needs coprime inputs, such as modular inverses
- Showing that coprime does not mean prime
- Practice at spotting a shared factor quickly
- Introducing Euler's totient as a count rather than a formula
- Reproducing the same pairs from a seed
How this generator works
Each candidate pair is tested with Euclid's algorithm and kept only if the greatest common divisor is one. The totient is computed by counting every value from 1 to the base that is coprime to it — slower than the product formula, and impossible to get subtly wrong. The check recomputes both.
Randomness and fairness
Which numbers appear is random; whether they are coprime is arithmetic. Seeded sets reproduce exactly and are therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator draws the numbers.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Numbers stop at 200, which keeps the direct totient count instant.
- Pairs only — mutual coprimality across three or more numbers is a stronger condition and is not tested.
- The counterexample is the first non-coprime pair drawn, not a chosen illustration.
- No factorisation is shown for each pair; the gcd is the point.
- Sets are not stored between visits; seed one you want again.
Privacy and your data
Numbers and their factors are computed in your browser. Nothing about the pairs or your seed is transmitted or kept.
Related generators
- Modular Arithmetic Question GeneratorRemainders, modular powers by repeated squaring, and inverses that only exist when the values are coprime.
- Random Prime Number GeneratorA prime number within a range you choose, verified prime rather than just plausible-looking.
- GCD and LCM Question GeneratorHighest common factor and lowest common multiple questions with Euclid's algorithm written out and the product identity checked.
- Prime Factorisation Question GeneratorPrime-factorisation questions built to order, answered in index form, with the factors checked to be prime.