Divisor (source code)

= Divisor
{title2=$d\mid n$}
{wiki}

= Integer divisor
{synonym}

A divisor of an <integer> $n$ is an <integer> $d$ satisfying the <divisibility> relation $d\mid n$. Equivalently, $n=dk$ for some <integer> $k$. The word \b[positive] matters when listing or counting <divisors>: unless signs are restricted, both $d$ and $-d$ qualify.

The positive <divisors> of $12$ are
$$
1,2,3,4,6,12.
$$
Their negatives are also <divisors> of $12$, giving twelve <integer divisors> altogether. The same list of positive <divisors> works for $-12$. One has only the positive <divisor> $1$, while zero has every <integer> as a <divisor>, including zero under our <divisibility> convention. A nonzero <integer> never has zero as a <divisor>.

For a <positive integer> $n$, the positive <divisors> come in pairs $(d,n/d)$ whose <product> is $n$. For $12$, the pairs are $(1,12)$, $(2,6)$ and $(3,4)$. Each pair contains a <divisor> at most $\sqrt n$, so searching through candidate <divisors> up to the <square root> suffices to find all pairs. A pair repeats its own member only when $n$ is a <perfect square>; for $36$, the middle pair is $(6,6)$. Consequently a <positive integer> has an odd number of positive <divisors> exactly when it is a <perfect square>.

The <prime factorization> gives another complete description. Since $12=2^2\cdot3$, its positive <divisors> are precisely $2^i3^j$ with $0\leq i\leq2$ and $0\leq j\leq1$. These independent choices give $(2+1)(1+1)=6$ positive <divisors>, the value of the <divisor function> $\tau(12)$. A <prime factor> is one particular kind of <divisor>; $4$, $6$ and $12$ show that <divisors> need not be <prime numbers>.

Thinking in pairs connects exact grouping with <integer factorization>: twelve objects can form three groups of four or four groups of three. Thinking in shared <divisors> gives the <greatest common divisor>; for $12$ and $18$, the positive common <divisors> are $1,2,3,6$, and the largest is $6$.