I am getting an NZEC on this solution. I can’t figure out what could be the problem. I have read that Ruby handles large numbers dynamically and I do not need BigNum for this.

My solution link is here, any help will be very much appreciated.

link to my solution

Actually I don’t know Ruby …The best help I can provide you is that in this problem you need Dynamic Programming implementation…If you are programming in C , C++ , python , Java …Do comment , I can help you then

use unsigned long int for c

In C, how can you store all the possible values of n till 1,000,000,000?

How would you do it in C?

Use long int and if you want to be on safe side like for addition or multiplication you may use long long int that has a range of -2^64 -1 to 2^64 -1