public class factorial {
public static void main(String[] args) {
Scanner k=new Scanner(System.in);
System.out.print("Enter a number: ");
int n=k.nextInt();
float s=1;
for(int i=1;i<=n;i++)
s=s*i;
System.out.println("The factorial is: "+s);
}
}
OUTPUT:
Enter a number: 5
The factorial is: 120.0
Enter a number: 5
The factorial is: 120.0
No comments:
Post a Comment