SPP Recursive Sequence

This is my code, Its giving the wrong answer. Can you check why? https://ide.codingblocks.com/s/217548

@duttrohan0302
Hey your code has very high time complexity upto 10^18 which makes this solution infeasible.

What you should have done is find sum of first n elements and find sum of first m - 1 elements. And subtract them to get sum of element in range(m, n). You need to find the sums using matrix exponentiation (O(logn)) time.