# WARNING: The text below provides a guidance for a Project Euler problem.

• If you pride yourself in tackling problems entirely on your own, you are encouraged to exit this post right now.

• If you are simply looking for a hint for the problem, please visit the »Project Euler’s official forum«. You may find some hints here, but if you don’t want your problem spoiled, scroll cautiously.

• If you are looking for a readily available copy/paste answer, you will not find it here. All of the code snippets in the post have been stripped of some crucial lines (these are clearly marked). It is my aim that anyone able to replicate the answer based on such snippets will have to understand the solution conceptually. At that point, by virtue of learning something new, I believe he deserves it anyway.

• Guidance for future problems will not be published before 100 people have solved the problem and there are at least two more recent problems.



### A long row of dice

Striping the problem of its dicey narrative, the task boils down to finding the value $f(10^{36})$ of the following function $f$:

where $\sigma_0(n)$ is the divisor function, that is a function that counts the number of positive divisors. We now turn to characterise numbers $n$ for which it is the case that $\sigma_0(n) \equiv 1 \text{ mod } 6$. For this, recall the standard formula (when we know the prime factorization of $n = \prod_{i=1}^r p_i^{\alpha_i}$):

Assuming that $\prod_{i=1}^r (\alpha_i + 1) \equiv 1 \text{ mod } 6$, we immediately see that none of the $(\alpha_i + 1)$ can be 0, 2, 3, or 4 (by simply looking at this equation modulo 2, 3) modulo 6. Each $(\alpha_i + 1)$ thus gives remainder 1 or 5 = -1, and each $\alpha_i$ gives remainder 0 or 4 modulo 6. Moreover, the number of $(\alpha_i + 1)$’s giving remainder -1 must be even. Going back to the prime factorization of number $n$, we may rewrite it as:

and pulling together the sixth powers:

Here now comes the crucial observation: to construct an integer $n$ satisfying the above relation, the first chunk $(q_1 \cdots q_{2u})$ can be taken to be any integer $B$ for which the Möbius function $\mu(B) = 1$ (this comes straight from the definition of the Möbius function). Afterwards the first chunk, $( p_1^{k_1} \cdots p_m^{k_m} q_1^{l_1} \cdots q_{2u}^{l_{2u}} )$, can be set to be an arbitrary integer! For a fixed value of $B$, there will be hence $\left\lfloor \sqrt[6]{\frac N {B^4}} \right\rfloor$ possible values for $A$ among $1, 2, \dots, N$. This yields a feasible formula for $f(N)$:

The following piece of compact Julia code gives answer in a (somehow) reasonable time. The bottleneck here is the unnecessary computation of all of the values of the Möbius function.