Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

factorial program in java

public class Factorial {

    public static void main(String[] args) {

        int num = 10;
        long factorial = 1;
        for(int i = 1; i <= num; ++i)
        {
            // factorial = factorial * i;
            factorial *= i;
        }
        System.out.printf("Factorial of %d = %d", num, factorial);
    }
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #factorial #program #java
ADD COMMENT
Topic
Name
9+4 =