Find the prime powers, multiply them back together, and count the divisors.
fundamental-theorem-of-arithmetic-le.le · output · proof · check · playground
The question
What are the prime factors of 360 and 10403? How many positive divisors
does each have? The fundamental theorem of arithmetic says every integer
greater than 1 is a product of primes, unique up to their order. We write
each prime power as [prime, exponent], with the primes in increasing order.
Historical background
Euclid treated the ingredients of prime factorization separately. Book VII proves that a prime dividing a product divides one of its factors, and that every composite number has a prime divisor. Those statements support the two parts of the modern theorem. Finding factors repeatedly gives existence, and canceling matching primes gives uniqueness. Euclid’s Elements, Book VII, Proposition 30 · Proposition 31
Finding the factors
Trial division starts at 2 and then tries the odd candidates. The first divisor greater than 1 must be prime, since any smaller prime factor of that divisor would already have divided the original number. A composite number has a factor at most its square root, so after the candidate’s square exceeds the cofactor, the cofactor itself is prime if it is greater than 1.
For 360, three divisions by 2 leave 45. Two divisions by 3 leave 5, and one division by 5 leaves 1. Each division shrinks the cofactor and each group records the number of times that prime divides it. For 10403 the first divisor found is 101, leaving the prime 103.
What eyemind concludes
% query factorizations with scenario integers
1 has prime powers [] and a positive divisor count of 1.
49 has prime powers [[7, 2]] and a positive divisor count of 3.
97 has prime powers [[97, 1]] and a positive divisor count of 2.
360 has prime powers [[2, 3], [3, 2], [5, 1]] and a positive divisor count of 24.
10403 has prime powers [[101, 1], [103, 1]] and a positive divisor count of 4.
12157665459056928801 has prime powers [[3, 40]] and a positive divisor count of 41.
A divisor of 360 chooses an exponent for each prime. For 2 the choices are 0 through 3, for 3 they are 0 through 2, and for 5 they are 0 or 1. This gives 4 × 3 × 2 = 24 divisors. The empty product for 1 gives just one divisor. The last input is 3⁴⁰, which the program reconstructs with exact integers.
struct('le:answer', 'factorizations', 'integers', 360, [[2, 3], [3, 2], [5, 1]], 24)
struct('le:answer', 'factorizations', 'integers', 12157665459056928801, [[3, 40]], 41)
Why the factors are unique
Take two prime factorizations of the same integer. By Euclid’s lemma, a prime in the first product divides at least one prime in the second product. It must equal that prime. Cancel the pair and repeat until both products are exhausted. This also shows why every distinct choice of exponents gives a different divisor. Euclid’s Elements, Book VII, Proposition 30
What the proof establishes
The saved proof is checked against the compiled Logic Script program.
It verifies the candidate tests and divisions that produce the six lists,
the exact products that recover the inputs, and the divisor counts.
--explain follows the same steps in Logical English.
Try it
node bin/eyemind.js examples/fundamental-theorem-of-arithmetic-le.le
node bin/eyemind.js --explain examples/fundamental-theorem-of-arithmetic-le.le
node bin/eyemind.js --check-proof examples/proof/fundamental-theorem-of-arithmetic-le.js examples/fundamental-theorem-of-arithmetic-le.le
