Project Euler Problem 708

A positive integer, n, is factorised into prime factors.

Project Euler Problem 708

Solution

Answer: 28874142998632109

Let

$$f(n)=2^{\Omega(n)},$$

where $\Omega(n)$ is the total number of prime factors of $n$ counted with multiplicity.

The Dirichlet series is

$$\sum_{n\ge1}\frac{f(n)}{n^s} =\prod_p \left(1+\frac2{p^s}+\frac{2^2}{p^{2s}}+\cdots\right) =\prod_p \frac{1-p^{-2s}}{(1-p^{-s})^2} =\frac{\zeta(s)^2}{\zeta(2s)}.$$

Using the Euler product decomposition,

$$f=d*g,$$

where $d(n)$ is the divisor function and $g$ is supported only on powerful numbers. Hence

$$S(N)=\sum_{n\le N} f(n) =\sum_{b\le N} g(b),D!\left(\frac Nb\right),$$

with

$$D(x)=\sum_{n\le x} d(n).$$

The divisor summatory function is computed exactly via

$$D(x)=2\sum_{i=1}^{\lfloor\sqrt{x}\rfloor}\left\lfloor\frac{x}{i}\right\rfloor-\lfloor\sqrt{x}\rfloor^2.$$

A DFS over powerful numbers evaluates the sum efficiently.

The implementation reproduces the check value

$$S(10^8)=9613563919.$$

Running the exact computation for $N=10^{14}$ gives:

Answer: 28874142998632109