Prime numbers, factorisation, and how the check stays fast
A prime number is a whole number greater than 1 that only 1 and itself divide evenly. The first few are 2, 3, 5, 7, 11 and 13. Every other whole number above 1 is composite, which means it is a product of smaller primes. 91 looks prime at a glance, but it is 7 × 13. Every composite number splits into primes in exactly one way, apart from the order. This is the fundamental theorem of arithmetic, and it is why primes are called the building blocks of the whole numbers.
The simplest test is trial division: try every number up to the square root, and if none divides evenly, the number is prime. For 97 you try 2, 3, 5 and 7, since 11 squared is already 121. That is fine for small numbers, but for a 20-digit number the square root has 10 digits, and trying billions of divisors would freeze the page. This tool uses the Miller-Rabin test instead. It checks a few properties that every prime has, using twelve fixed test values. With those twelve values the test has been proved to give no wrong answers below about 3.3 × 10^24, so for every number this tool accepts the answer is certain.
Finding the factors of a composite number is harder than knowing that it has some. The tool first divides out small primes below 1,000. What remains is split with Pollard's rho method, which finds a factor in roughly as many steps as the square root of that factor. The hardest case under 20 digits is two 10-digit primes multiplied together, and even that takes a fraction of a second. A perfect square, such as a large prime times itself, is caught by a square root check before rho starts.
The result also lists the number of divisors and the primes on either side. The divisor count comes from the factorisation: 360 is 2³ × 3² × 5, and adding 1 to each exponent and multiplying gives 4 × 3 × 2, so 360 has 24 divisors. The neighbouring primes show how primes thin out. Below 100 they are a few apart. Near 20-digit numbers the average gap is about 46, though some gaps are much wider.
Some limits are worth knowing. The tool takes whole numbers of up to 20 digits, so it cannot test the record primes with millions of digits, or factor the 600-digit numbers used in RSA encryption. Those are hard to factor on purpose, and no known method can do it in any reasonable time. The number 1 and the number 0 are neither prime nor composite, and negative numbers are refused, because primality is defined for positive whole numbers.