Write an application that displays the factorial for every integer value from 1 to 10. A factorial of a
number is the product of that number multiplied by each positive integer lower than it. For
example, 4 factorial is 4 * 3 * 2 * 1, or 24.
public static void main() {
int result = 1;
for(int i = 1; i <= 10; ++i) {
result = result * i;
System.out.println("Factorial of " + i + " is " + result);
}
}
Comments
Leave a comment