Print Friendly and PDF

Program

import java.util.*;
class Factorial
{
int fact(int x)
{
if(x>1)
return x*fact(x-1);
else
return x;
}
public static void main(String[] args)
{
int a,c;
Factorial F1=new Factorial();
Scanner S=new Scanner(System.in);
System.out.println("Enetr an integer value");
a=S.nextInt();
c=F1.fact(a);
System.out.println("Factorial is:" +c);
}
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: