Divisor Count Function is Primitive Recursive

Theorem
The divisor counting ($\tau$) function is primitive recursive.

Proof
The divisor counting function $\tau: \N \to \N$ is defined as:
 * $\ds \map \tau n = \sum_{d \mathop \divides n} 1$

where $\ds \sum_{d \mathop \divides n}$ is the sum over all divisors of $n$.

Thus we can define $\map \tau n$ as:
 * $\ds \map \tau n = \sum_{y \mathop = 1}^n \map {\operatorname {div} } {n, y}$

where
 * $\map {\operatorname {div} } {n, y} = \begin{cases}

1 & : y \divides n \\ 0 & : y \nmid n \end{cases}$

Hence $\tau$ is defined by substitution from:
 * the primitive recursive function $\operatorname {div}$
 * the primitive recursive bounded summation $\ds \sum_{y \mathop = 1}^n$.

Hence the result.