[Solved] factorial giving wrong answer


I think the reason why you are getting “random” numbers is because you haven’t initialized the carry variable. In the for loop, you are adding the un-initialized value of carry to the array which will cause undefined results.

solved factorial giving wrong answer