# Factorial program

#### Factorial program in c

``` #include<stdio.h> #include<conio.h> int Factorial(int fact); void main() { int input; printf("Enter your number \n"); scanf("%d",&input); printf("Result = %d",Factorial(input)); getch(); } int Factorial(int fact) { int total = 1; for (int i = fact; i >= 1; i--) { total *= i; } return total; } ```

#### Output

```Enter your number 3 Result = 6 ```

#### Factorial program in c++

``` #include<iostream> #include<conio.h> using namespace std; class FactorialNumber { public: int Factorial(int fact) { int total = 1; for (int i = fact; i >= 1; i--) { total *= i; } return total; } }; void main() { FactorialNumber factorialNumber; int input; cout<<"Enter your number \n"; cin>>input; cout<<"Result = "<<factorialNumber.Factorial(input); getch(); } ```

#### Output

```Enter your number 4 Result = 24 ```

#### Factorial program in c#

``` using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FactorialNumberProgram { class FactorialNumber { public int Factorial(int fact) { int total = 1; for (int i = fact; i >= 1; i--) { total *= i; } return total; } static void Main(string[] args) { FactorialNumber factorialNumber = new FactorialNumber(); Console.WriteLine("Enter your number"); int number = Convert.ToInt32(Console.ReadLine()); Console.Write("Result = " + factorialNumber.Factorial(number)); Console.ReadLine(); } } } ```

#### Output

```Enter your number 5 Result = 120 ```

#### Factorial program in java

``` import java.util.*; class FactorialNumber { public int Factorial(int fact) { int total = 1; for (int i = fact; i >= 1; i--) { total *= i; } return total; } } class examples { public static void main(String[] args) { FactorialNumber factorialNumber=new FactorialNumber(); Scanner obj= new Scanner(System.in); int input; System.out.println("Enter your number"); input=obj.nextInt(); System.out.print("Result = "+factorialNumber.Factorial(input)); } } ```

#### Output

```Enter your number 6 Result = 720 ```

### Write a comment

Name Email Message