Project Euler Problem 861

A unitary divisor of a positive integer n is a divisor d of n such that gcdleft(d,frac{n}{d}right)=1.

Project Euler Problem 861

Solution

Answer: 255098778

Let

$$n=\prod p_i^{a_i}.$$

For a prime power $p^a$, the bi-unitary divisors are all $p^e$ with $0\le e\le a$, except that when $a$ is even, $e=a/2$ is excluded.

Hence the number of bi-unitary divisors of $p^a$ is

$$\tau^{**}(p^a)= \begin{cases} a+1,& a\text{ odd},\ a,& a\text{ even}. \end{cases}$$

Equivalently,

$$\tau^{**}(p^a)=2\left\lceil \frac a2\right\rceil .$$

The product of all bi-unitary divisors of $p^a$ is

$$P(p^a)=p^{a\tau^{**}(p^a)/2}.$$

By multiplicativity,

$$P(n)=n^{\tau^{**}(n)/2},$$

where

$$\tau^{}(n)=\prod_i \tau^{}(p_i^{a_i}).$$

Therefore

$$P(n)=n^k \quad\Longleftrightarrow\quad \tau^{**}(n)=2k.$$

So the problem becomes counting integers $n\le 10^{12}$ such that

$$\tau^{**}(n)\in{4,6,8,\dots,20}.$$

A complete enumeration of admissible exponent patterns together with a prime-counting recursion gives the required total.

$$\sum_{k=2}^{10} Q_k(10^{12}) = 255098778$$

Answer: 255098778