Skip to content

Factors, GCD & LCM

Factorises an integer and computes GCD, LCM, divisors and primality for one or several numbers.

Splits a whole number into its prime factors and tells you the divisors, the divisor sum, Euler’s φ and the neighbouring primes. Give it several numbers instead and it computes the GCD and the LCM. The arithmetic is exact at any size, so numbers past 2^53 behave properly.

🔒 Runs entirely in your browsermathprimegcdnumber-theory

One number

Any size. Everything here is exact integer arithmetic, so numbers past 2^53 — where a spreadsheet stops telling consecutive integers apart — are handled properly.

Factorisation

360 = 2^3 × 3^2 × 5

prime?

no

digits

3

divisors

24

sum of divisors

1,170

Euler φ

96

coprimes below it

perfect?

no

equals the sum of its proper divisors

next prime

367

previous prime

359

Divisors (24)

1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 120, 180, 360

Several numbers

greatest common divisor

6

least common multiple

5,040

One per line, or separated by commas.

Primality is a proof, not a probability. Miller–Rabin is a probabilistic test in general, but with the first thirteen primes as its bases it is proven to have no composite exception below 3.3 × 10²⁴ — comfortably past anything you can type here. Large composites are split with Pollard’s rho after trial division, which is what lets a product of two fifteen-digit primes come apart in milliseconds.

How to use it

  1. Type one number

    Digits, optionally with commas. The factorisation, the divisors and the primality verdict all appear together.

  2. Or several, for GCD and LCM

    One per line or comma-separated. This is the panel you want for reducing a set of fractions or working out a repeat interval.

  3. Read the neighbours when you need a prime

    The next and previous primes are shown, which is what you are after when you want a prime near a particular size for a hash table or a modulus.

Common questions

Why did it refuse a large number?

Testing whether a number is prime is fast at any size; splitting it is the expensive direction. Pollard’s rho runs in roughly the fourth root of the number — milliseconds at twenty digits, many seconds past forty, in one call the browser cannot interrupt. Rather than freeze the tab, it stops and still tells you whether the number is prime.

Is 1 prime?

No, by definition — a prime has exactly two distinct divisors, and 1 has one. Excluding it is what makes prime factorisation unique, which is the whole reason the definition is drawn there.

What is Euler’s φ for?

It counts the numbers below n that share no factor with it. It is the size of the multiplicative group modulo n, which is what makes RSA work, and it is also the period of a repeating decimal 1/n when n is coprime to ten.

Feed it from

Next

These accept what this tool produces, so the result can go straight in.