Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

factorial program

#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)
Comment

Program for factorial of a number

// 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
Comment

Program for factorial of a number

// 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));
    }
}
Comment

Program for factorial of a number

// 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));
    }
}
Comment

Program for factorial of a number

// 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;
}
Comment

PREVIOUS NEXT
Code Example
Python :: find the sum of all the multiples of 3 or 5 below 1000 python 
Python :: how to play audio in python 
Python :: python append to first index 
Python :: how to print a matrix in python 
Python :: check if date is valid python 
Python :: SciPy 1D Interpolation 
Python :: replace character in string python 
Python :: python snakes 
Python :: true positive true negative manually 
Python :: python input function 
Python :: django __str__ self multiple 
Python :: replace value pandas df 
Python :: change colorbar size and place python 
Python :: construct contingency table from pandas 
Python :: delete rows with value in column pandas 
Python :: exeption python syntax 
Python :: find common values in different dataframes pandas 
Python :: python numphy how to use fractions 
Python :: get all file in folder python 
Python :: manipulate ip address in python 
Python :: __call__ python 
Python :: python keyboardinterrupt 
Python :: template string python 
Python :: install imgkit py 
Python :: make entry bigger in tkinter python 
Python :: Adjusting Subplot Margins in Matplotlib 
Python :: enum python 
Python :: python password hashing 
Python :: seaborn bar plot 
Python :: input and ouput array in python 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =