# Need help with my code(C)

I am solving this problem https://www.codechef.com/problems/FCTRL2/
and my solution is this: https://www.codechef.com/viewsolution/23682875.
While it seems to be working fine for small numbers like 10, 20, its not working with large numbers. Can anyone explain?
What’s wrong with this approach?

Instead of making the viewers go through your entire code and find out your approach used and try guessing the logic behind it, make a detailed question including all your approach and logic and after ensuring that your logic is sound, post you question back.
Otherwise, you will mostly end up with posts by others leading you to their solution, because the fact being said, not everyone has the time to go through someone else’s code(though some good-hearted people do!)
Also you might find the editorials on the question page, through which you can check whether your logic is correct.

Thanks! Will check out the editorial then.

The reason is you are doing lot of multiplication due to which the value of fact[i] for large value of i overflows. As size of double in C is only around 8 bytes which can store values less then 2^53.

1 Like