Share your repls and programming experiences

← Back to all posts
Write a program to find factorial of a number using for loop in java
RaghunathThilag (1)

Write a program to find factorial of a number using for loop in java. In this program you will learn how to write a program to print factorial number or not program in java using for loop. In the Java programming language, program a factorial number or not. This is a simple program that determines whether a number is factorial or not.

public class Main
{
public static void main(String[] args)
{
int num = 15;
long factorial = 1;
for(int i = 1; i <= num; ++i)
{
factorial = factorial * i;
}
System.out.printf("Factorial of %d is", factorial);
}
}

Output:

Factorial of 15 is 1307674368000

Link: https://inlarn.com/write-a-program-to-find-factorial-of-a-number-using-for-loop-in-java/