Factorial

 

            Write a flowchart for a program which calculates the factorial (n!) of n. n is an integer number entered from the keyboard. The result, factorial of n is displaced on the PC monitor.

n! = n*(n-1)*(n-2)*…….*1

Two variables are needed in the program:

                        n:          n   

                        res:       n!

 

            Depending on which software to use, some software requires to declare all the variables used in the program. Declaration and initialization of variables are normally at the beginning of a program.

 

Here is the flowchart:

To check the flowchart, give a number to n, for example n=3, follow the flowchart, the output res should be 6.