|
|
g(2005) = ((2002 * g(2004) + 2003 * g(2003)) % 2005 g(2004) = ((2002 * g(2003) + 2003 * g(2002)) % 2005 g(2003) = ((2002 * g(2002) + 2003 * g(2001)) % 2005 g(2002) = ((2002 * g(2001) + 2003 * g(2000)) % 2005 (...) g(3) = ((2002 * g(2) + 2003 * g(1)) % 2005 g(2) = ((2002 * g(1) + 2003 * g(0)) % 2005 g(1) = 1 g(0) = 0 |
|
|
Also, how much time does it take the program to output the solution? |
But how should I deal with the % 2005? I'm pretty bad with number theory and don't deal with % quite often in Math. I have no idea how to proceed. |
X % 2005
there are more cases...X == 2005 * Y
then the result is 0 (Y can also be 0)X == 2005 + Y
then the result is Y (for Y positive and not part of case 1)X == 2005 - Y
then the result is X (for Y positive and not part of case 1)g(2005)
.Edit 3: I'd also like to see your iterative version, my brain is dead. |
|
|
You can't take modulus of this because 2003^2005 is too big |