Quote:This program uses algorithm to work on recursion yes or no? If not how will improve this code?
Yes. Sort of. It only ever returns 120, regardless of the value I put in
Factorial of 3 is 120
To improve it? Don't calculate it at all. Instead, precalculate all the ones which fit in a 32 bit integer. Since there are only 13 of them (0! to 12! inclusive) it's simpler, quicker, and a lot more memory efficient to allocate an array of 13 integers, and just check that the requested value is in range. Your app either crashes or gives the wrong value if I request 13! or above ...