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
Error with large value
in this i am using iteration as suggested but same problem still exist