# Write a program in C++ & python to calculate the Factorial of an Integer

Posted in  Vinay Khatri
Last updated on July 21, 2022

In this program, we will code to calculate the factorial of an integer. Factorial is a math concept which has a! sign For example, 3 factorials would be represented as 3! = 3*2*1 0! = 1

## Write a program to find the factorial of an Integer

### C++ Program to Find the Factorial of and Integer

``````#include<iostream.h>
#include< conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int num,fact=1;
cout<<"Enter a number: ";
cin>>num;
for(int i=1; i<=num; i++)
fact *= i;
if(num==0)
cout<<"The factorial is 1";
else
cout<<"The factorial of "<<num<<" is "<<fact;
getch();
}``````

Output:

``````Enter a Number: 5
The factorial of 5 is 120``````

### Python Program to Find the Factorial of and Integer

``````num =int(input("Enter a Number: "))
fact=1
for i in range(1,num+1):
fact*=i
if num==0:
print("The factorial is 1")
else:
print("The factorial of",num,"is",fact)``````

Output:

``````Enter a Number: 6
The factorial of 6 is 720``````

People are also reading:

##### Tags:
factorial of an integer