Factorial Number
import java.io.*;
public class Factorial
{
public static void main(String[] args)throws IOException
{
int n,i,c=1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Number to Find Factorial :-");
n= Integer.parseInt(br.readLine());
for(i=1;i<=n;i++)
{
c = c*i; // Calculating Factorial
}
System.out.println("The Factorial is : " + c);
}
}
/*
Example:-
Enter Number to Find Factorial :-
INPUT :-
5
OUTPUT :-
The Factorial is : 120
*/
public class Factorial
{
public static void main(String[] args)throws IOException
{
int n,i,c=1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Number to Find Factorial :-");
n= Integer.parseInt(br.readLine());
for(i=1;i<=n;i++)
{
c = c*i; // Calculating Factorial
}
System.out.println("The Factorial is : " + c);
}
}
/*
Example:-
Enter Number to Find Factorial :-
INPUT :-
5
OUTPUT :-
The Factorial is : 120
*/
Comments
Post a Comment