Chris Collins

Tools · math

Number theory

Arbitrary-precision integer tools — primality, factorisation, divisor functions, GCD and modular arithmetic, the Chinese remainder theorem, bases, repeating decimals, continued fractions, big factorials, and Roman numerals.

Added · updated 14 October 2026

How to use it

All integer work uses exact arbitrary-size integers (BigInt). Inputs accept decimal, 0x, 0b, and 0o literals with _ separators.

  • Primes & factors: Miller–Rabin primality (deterministic below 3.3 × 1024, probabilistic above), factorisation by trial division and Pollard’s rho, τ, σ, φ, μ, ω, and Ω, all divisors, the neighbouring primes, and a sieve listing primes up to 20 million.

  • GCD & modular: gcd and lcm with Bézout coefficients, modular exponentiation and inverse, and solving a·x ≡ b (mod m). The Chinese remainder theorem accepts one congruence per line (2 mod 3) and handles moduli that are not coprime.

  • Bases & fractions: any base from 2 to 36; fractions to decimals with the repeating part in brackets (1/7 = 0.(142857)) and back; continued fractions and best rational approximations (π → 22/7, 355/113…).

  • Big numbers: exact n!, C(n, r), P(n, r), Fibonacci numbers by fast doubling, 2n, and Catalan numbers.

  • Roman numerals: both directions, 1–3999.

Factorising numbers whose two largest prime factors are both beyond about 20 digits can exceed the four-second limit.

Sharing

Share link (under the title) copies a URL that reopens this tool exactly as you have it — every tab’s inputs, with the current tab selected. Opening such a link replaces the inputs this browser had saved for the tool.

Linking to an example

Companion to chapters 1, 2 and 23 (numbers, fractions and decimals, number theory) of Mathematics, Reconnected. Each input box has a short parameter, and the tab comes from the # part of the address, for example /tools/numbers/?a=1071&b=462#gcd or ?frac=1/7#bases. Share link writes the same parameters.

Tab Parameter Meaning Example

#factor

n

integer to test and factorise

n=391

#factor

sieve

list the primes up to this

sieve=400

#gcd

a, b

gcd, lcm and Bézout coefficients of a and b

a=1071&b=462

#gcd

m, e

modulus and exponent: a mod m, aᵉ mod m, a⁻¹ mod m, and a·x ≡ b

a=7&e=13&m=11

#gcd

crt

congruences a mod m, separated by ;

crt=2 mod 3;3 mod 5

#bases

num, base

a number written in base base (2–36), shown in other bases

num=ff&base=16

#bases

frac

a fraction to a repeating decimal, or a repeating decimal back (0.1(6))

frac=1/7

#bases

x

best rational approximations of a real number (pi, e, √2, phi or a decimal)

x=pi

#combi

big, r

n!, C(n, r), P(n, r), Fibonacci, 2ⁿ and Catalan for n = big

big=100&r=7

#roman

roman

a number or Roman numeral

roman=MMXXVI

example

one of the presets below (it also picks the tab); other parameters override it

example=ch23-jugs-3-5

Presets:

Runs entirely in your browser; nothing you type leaves this page.