 Last Updated:

# C program to find factorial of a number ## Algorithm

Input: Input a number
output: Find and displays factorial of a number

1. Start
2. Input a numbers say n to find factorial
3. sum = 1
4. for (int i = 1; i<= n; i++)
4.1 sum = sum * i
5. print sum
6. stop

## C Program #include <stdio.h>
int main( )
{
int n,sum = 1;
printf("Enter a number to find the factorial: ");
scanf("%d", &n);
for(int i = 1; i <= n ; i++) {
sum = sum * i;
}
printf("The factorial of %d is %d", n , sum);
}

Note: This Program was created using visual studio code. The Program file can be downloaded by clicking here

# FlowChart

Note: This Flowchart was created using a program called Raptor. The flowchart file can be downloaded by clicking here

###### Inputn:5OutputThe factorial of 5 is 120

Note: Please read the explanation of how I implemented the Fibonacci series in 'C program to display fibonacci series' to understand the logic of factorial too. The explanation of Fibonacci can be viewed by clicking here.