int n = 6; // where n is a non-negative integer
int count=1, product=1, factor=1;
do{
product = product * factor++;
count++;
}while(count <= n);
System.out.println(n + "! = " + product);
Showing posts with label count. Show all posts
Showing posts with label count. Show all posts
Factorial Code Snippet
Here's a Java code example for Factorial. In this example, we will compute for the Factorial of 6 which is denoted by variable n:
Subscribe to:
Posts (Atom)

