#factorial of n integer
a=int(input('Enter a number :'))
fact=1
for i in range(1,n+1):
fact*=i
print('Factorial of',a,'is',fact)
// C++ program to find factorial of given number
#include <iostream>
using namespace std;
// function to find factorial of given number
unsigned int factorial(unsigned int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
// Driver code
int main()
{
int num = 5;
cout << "Factorial of "
<< num << " is " << factorial(num) << endl;
return 0;
}
// This code is contributed by Shivi_Aggarwal
// Java program to find factorial of given number
class Test {
// method to find factorial of given number
static int factorial(int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
// Driver method
public static void main(String[] args)
{
int num = 5;
System.out.println("Factorial of " + num
+ " is " + factorial(5));
}
}
// Java program to find factorial of given number
class Test {
// method to find factorial of given number
static int factorial(int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
// Driver method
public static void main(String[] args)
{
int num = 5;
System.out.println("Factorial of " + num
+ " is " + factorial(5));
}
}
// C program to find factorial of given number
#include <stdio.h>
// function to find factorial of given number
unsigned int factorial(unsigned int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
int main()
{
int num = 5;
printf("Factorial of %d is %d", num, factorial(num));
return 0;
}