0% found this document useful (0 votes)
2 views1 page

Java Program to Calculate Factorial

The document is a Java program that calculates the factorial of a given number. It prompts the user to enter a number and computes the factorial using a loop. If the input is zero, it outputs that the factorial is 1.

Uploaded by

mystical Coder
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Java Program to Calculate Factorial

The document is a Java program that calculates the factorial of a given number. It prompts the user to enter a number and computes the factorial using a loop. If the input is zero, it outputs that the factorial is 1.

Uploaded by

mystical Coder
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

public static void main(String[] args)

{
int n,i,fact=1;

Scanner input=new Scanner([Link]);

[Link]("Enter Number : ");


n=[Link]();

if(n==0)
{
[Link]("Factorail of %d is : 1",n);
}
else
{
for(i=1;i<=n;i++)
{
fact=fact*i;
}

[Link]("Factorial of %d : %d",n,fact);
}

You might also like