How to Create a Program to Find a Factorial of a Number in Core Java

In this tutorial how to find a Factorial of a number in Core Java  is shown.

Code:

Factorial.java

class Fact
{
public static void main(String args[])
{
int number=Integer.parseInt(args[0]),fact=1,i;
for(i=number;i>0;i–)
{
fact*=i;
}
System.out.println(“Factorial of “+number+” is “+fact);
}
}

Add a Comment

Your email address will not be published. Required fields are marked *