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 class Factorials
{
public static void main (String args[])
{
final int MAX = 10;
int factorial;
for (int i = 1; i <= MAX; i++)
{
factorial = i;
for(int j = i - 1; j > 0; --j)
factorial = factorial * j;
System.out.println("The factorial of " + i +" is " + factorial);
}
}
}

Computer Science & Information Technology

You might also like to view...

Modify example program 2 to average four numbers read from a list.

Add a fourth value to the data list
Replace DO WHILE count < 3	with DO WHILE count < 4

Computer Science & Information Technology

The symbol used to create a line that fills the space preceding a tab stop is called a(n) ________

A) drop cap B) anchor C) separator character D) leader character

Computer Science & Information Technology

The default output of decimal numbers of the type float is up to nine decimal places.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A distributed denial of service (DDoS) attack is a DoS attack launched from several machines

Indicate whether the statement is true or false.

Computer Science & Information Technology