Fectorial of a number
import java.util.*;class A
{
int a,i,f=1;
void get()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Value of a ");
a=sc.nextInt();
}
void put()
{
for(i=1;i<=a;i++)
{
f=f*i;
}
System.out.print("Fectorial Of "+a+" is "+f);
}
public static void main(String[] args)
{
A a=new A();
a.get();
a.put();
}}
No comments:
Post a Comment