[Solved] What is the logic behind this recursive program to find factorial in c++? [closed]
it is exactly like you said: 5*factorial(4)=5*4*factorial(3)=5*4*3*factorial(2)=5*4*3*2*factorial(1) So if it reaches 1 then this will be replaced by 5*factorial(4)=5*4*factorial(3)=5*4*3*factorial(2)=5*4*3*2*1 so the result of the last step goes into the second last step…. where 2*1 will be calculated… After that the 3rd last step gets the value of 2*1 = 2 and multiplies 3 on in … Read more