Error with large value


this is the link to my code
here i am getting correct value for lower value of n approx 30-40 but after 40 after 15 digit my ans start deviating from the final result
for eg: for 40
my ans =>2622127042276492312576
but online =>2622127042276492108820

@gagangoyal674 hey use dynamic programming ,instead of recursion to store subproblem results.

in this i am using iteration as suggested but same problem still exist

@gagangoyal674 hey you dont have used dp ,store subproblems result also,not only iterate.