We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
HOW DO I CALCULATE THE FACTORIAL OF A NUMBER?
Computer Science textbooks typically take factorial calculation as an example for recursive functions.
The 8051 is particularly unsuited to recursive functions, so that would not be a good choice if you're thinking of doing it on an 8051. An iterative approach would be more appropriate.
In general, recursion is best avoided in embedded systems...
Few functions are so well suited for an iterative solution as the factorial. I have never really understood why the factorial is the #1 example of recursion.