← Complete problem index

PROJECT EULER · #0641

A Long Row of Dice

Statement only · SolvedOriginal problem ↗

Consider a row of n dice all showing 1.

First turn every second die,(2,4,6,), 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 nth 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(108)=69.

Find f(1036).

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.