Here is my solution it is giving wrong and can anybody tell me what i am doing wrong???
Check the following points once:
- While multiplying the matrices just see if you are taking the mod correctly.
- I am not sure about your final answer as well, that 2*a. Just check if you are calculating the nth term correctly.
- Think about the power you should raise the matrix to.
Another important thing is that your code doesn’t have that matrix of the initial terms of the recurrence relation, you simply raise a matrix to some power and report the answer, that is wrong I think. For example in the Fibonacci numbers, we have a matrix [1 1], the initial values F1 and F2. Similarly, I think you should precompute the answers for W1, W2, W3, W4, W5, W6, which are the initial terms of the recurrence relation Wi = Wi-1 +Wi-2 + Wi-3 + Wi-4 + Wi-5 + Wi-6.