A Long Row of Dice

 Published on Saturday, 3rd November 2018, 01:00 pm; Solved by 401;
Difficulty rating: 35%

Problem 641

Consider a row of $n$ dice all showing 1.

First turn every second die,$ (2,4,6,\ldots)$, so that the number showing is increased by 1. Then turn every third die. The sixth die will now show a 3. Then turn every fourth die and so on until every $n$th die (only the last die) is turned. If the die to be turned is showing a 6 then it is changed to show a 1.

Let $f(n)$ be the number of dice that are showing a 1 when the process finishes. You are given $f(100)=2$ and $f(10^8) = 69$.

Find $f(10^{36})$.