AMC 12B 2015 Problem 20

For every positive integer n, let \bmod _{5}(n) be the remainder obtained when n is divided by 5 . Define a function f:\{0,1,2,3, \ldots\} \times\{0,1,2,3,4\} \rightarrow\{0,1,2,3,4\} recursively as follows:

f(i, j)= \begin{cases}\bmod _{5}(j+1) \text { if } i=0 \text { and } 0 \leq j \leq 4 \\ f(i-1,1) \text { if } i \geq 1 \text { and } j=0, \text { and } \\ f(i-1, f(i, j-1)) \text { if } i \geq 1 \text { and } 1 \leq j \leq 4\end{cases}

What is f(2015,2) ?

Answer Choices
A. 0
B. 1
C. 2
D. 3
E. 4