The factorial of a positive integer N, denoted by N!, is defined by the followin
ID: 3627790 • Letter: T
Question
The factorial of a positive integer N, denoted by N!, is defined by the following:
N! = 1 * 2 * ..... * N (Note: 0! = 1)
Using subprograms and functions, create a recursive program to compute N!. The user should input a positive integer and a subprogram should check that the input is correct ( a positive integer). Then use recursion to computer the factorial. Create a subprogram that will call itself to do the multiplication until N = 1. Then display the result in the main program.
Draw a flowchart and write a pseudo code for this program.
Explanation / Answer
The exact implementation can vary, but pseudo code for the factorial program looks like: fact (n) if (n < 0 or n is not an integer) then return ERROR; else if (n = 0) then return 1; else return n * fact(n-1); end ifRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.