Question: Find a formula for the Sprague-Grundy value $(g(n))$ of a pile of coins of size $n$ with a subtraction set $\{1,4,5\}$.
I was able to find the periodic pattern for $g(n)$ as $0,1,0,1,2,3,2,3$. However my problem with these kind of questions is finding the formula for the pattern of $g(n)$.
So, for $g(n)=0$ the pattern is $n=0,2,8,10,16...$
for $g(n)=1$ the formula is for all $n$ such that $(n$ mod $2) = 1$
for $g(n)=2$ the pattern is $n=4,6,12,14,20,22...$ I can't derive a formula for this pattern
for $g(n)=3$ the pattern is $n=5,7,13,15,21...$
I would like to know if there is a method or an approach to derive these formulas to get the $g(n)$?
Thank you.
Since you found the periodic pattern, you can simply represent $g(n)$ as:
$$g(n) = \begin{cases} 0 &\text{for } n = 0,2 \pmod 8 \\1 &\text{for } n = 1,3 \pmod 8 \\2 &\text{for } n = 4,6 \pmod 8 \\3 &\text{for } n = 5,7 \pmod 8\end{cases}$$
or, if you are not comfortable with modulos:
$$g(n) = \begin{cases} 0 &\text{for } n = 8k &\text{ or }8k+2 &\text{for some } k \in \mathbb N \\1 &\text{for } n = 8k+1 &\text{ or }8k+3 &\text{for some } k \in \mathbb N \\2 &\text{for } n = 8k+4 &\text{ or }8k+6 &\text{for some } k \in \mathbb N \\3 &\text{for } n = 8k+5 &\text{ or }8k+7 &\text{for some } k \in \mathbb N\end{cases}$$