Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java factorial loop

public class FactorialProgram
{
    public static void main(String[] args)
    {
        int number = 6;
        long factorial = 1;

        for (int i = 1; i <= number; i++)
        {
            factorial = factorial * i;
        }
        System.out.println("Factorial of " + number + " is: " + factorial);
    }
}
Source by www.javainterviewpoint.com #
 
PREVIOUS NEXT
Tagged: #java #factorial #loop
ADD COMMENT
Topic
Name
1+5 =