# Find factorial of a number using function

## Problem Statement:-  Program to print factorial of any given number using a user-defined function.

#### Sample Input/Output:-

 Sample Input First:5 Sample Output First: 120 Sample Input Second: 8 Sample Output Second: 40320

#### Data requirement:-

Input Data:- num

Output Data:-fact

Program in C

Code:

Program in C++

## Here is the source code of the C++ Program to print factorial of any given number using a user-defined function.

Code:

### ``import java.util.Scanner;public class FindFactorial {    /* This function find factorial of a number */    static long FactorialOfNumber(int num) {        long fact = 1;        for (int i = num; i >= 1; i--)            fact *= i;        return fact;    }    public static void main(String[] args) {        java.util.Scanner cs = new Scanner(System.in);        /* Get the number input */        System.out.print("Enter the Number:");        int num = cs.nextInt();        /* Display the factorial of a given number */        System.out.println("Factorial Given Number is: " + FactorialOfNumber(num));        cs.close();    }}``Input/Output:Enter the Number:9Factorial Given Number is: 362880

Program in Python

Code: