Factorial of a number

Factorial of a positive integer (number) is the sum of multiplication of all the integers smaller than that positive integer. For example, factorial of 5 is 5 * 4 * 3 * 2 * 1 which equals to 120.
A factorial is denoted by "!". So, suppose, you want to find the factorial of the number n, then n! = n * (n-1) * (n-2) * (n-3) … *. 
Now, let’s see how to write a C program for factorial of a number?
Algorithm of C Program for Factorial
The algorithm of a C program to find factorial of a number is:
Start program
Ask the user to enter an integer to find the factorial
Read the integer and assign it to a variable
From the value of the integer up to 1, multiply each digit and update the final value
The final value at the end of all the multiplication till 1 is the factorial
End program
Pseudocode of C Program for Factorial
Using the above algorithm, we can create pseudocode for the C program to find factorial of a number, such as:
procedure fact(num)
until num=1
fact = fact*(num-1)
Print fact
end procedure
Now that we know the basic algorithm and pseudocode to write a C program for factorial, let’s start implementing it using various methods.
Now, let’s start implementing it using various methods.
Posted on by