import java.util.*;
class Factorial{
public static void main(String args[]){
long fact=1,num;
int i;
Scanner s=new Scanner(System.in);
System.out.println("Enter number");
num=s.nextLong();
if(num>0){
for(i=1;i<=num;i++)
fact=fact*i;
System.out.println("Factorial of"+num+"="+fact);
}
else{
System.out.println("wrong number");
}}}
No comments:
Post a Comment