import java.util.Scanner;
class Factorial
{
int n;
//To initialize values
Factorial(int no)
{
n=no;
}
//To find factorial of number
void check()
{
int i,f=1;
for(i=1;i<=n;i++)
{
f=f*i;
}
System.out.println(" factorial is: "+f);
}
}
//To create object
class TestFactorial
{
public static void main(String args[])
{
int n;
Scanner a=new Scanner(System.in);
System.out.println("\nEnter number :- ");
n=a.nextInt();
Factorial obj=new Factorial(n);
obj.check();
}
}
0 Comments