I saw a question where it was just asking for the smallest number with n distinct divisors, but I'm looking for n distinct prime divisors. For example, the prime factorization of 8 is 2 * 2 * 2, so it has one distinct prime divisor. Another example is 12 (2 * 2 * 3), which has 2 distinct prime divisors. Is there a formula to do this (preferably one that can easily be implemented into python)? If n = 24, the smallest number with 24 distinct prime divisors is 23768741896345550770650537601358310.
2026-04-05 05:26:04.1775366764
how to find the smallest number with exactly n distinct *prime* divisors
65 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
The smallest number with $n$ distinct prime factors, and the $n$-th number in the list, is the primorial $p_n\#$ of the $n$-th prime $p_n$, like $p_4\# = 7\#=2\cdot3\cdot 5\cdot 7$. See also OEIS A002110.
$$\begin{align} 2 &= 2 \\ 6 &= 2\cdot3 \\ 30 &= 2\cdot3\cdot 5 \\ 210 &= 2\cdot3\cdot 5\cdot 7 \\ &\ \vdots \end{align}$$
There are formulas that generate primes, but none is well suited for computation.
For any practical purposes, first generate a list of primes, for example by a sieve algorithm like Eratosthenes'.
Because you will always only encounter small primes of just a few decimals, you can also generate list of primes by checking divisors up to $\sqrt n$, as the overhead should be neglectable compared to heave number-theoretic machinery like pseudo-primality test together with primality-proofs and -certificates.