Write an iterative method to compute the factorial of a number.

What will be an ideal response?


```
public static int iterativeFactorial(int n)
{
if(n < 0)
{
System.out.println(“Sorry negative numbers not allowed.”);
System.exit(0);
}

int result = 1;
for(int i = 1; i <= n; ++i)
{
result = result * i;
}
return result;
}

```

Computer Science & Information Technology

You might also like to view...

____ tasks include the addition of titles, credits, scene transitions, special visual effects, and sound effects.

A. Quality assurance B. Agile development C. Post-production D. Business analysis

Computer Science & Information Technology

JDBC 4 supports _______, so you do not need to manually load the database driver before accessing a database.

a. automatic driver downloading b. automatic driver creation c. automatic driver discovery d. None of the above.

Computer Science & Information Technology

Identify the letter of the choice that best matches the phrase or definition.

A. Built-in function that calculates the payments for a loan based on constant payments and a constant interest rate B. Class that provides standard math procedures required for mathematical calculations C. Math class method that returns the absolute value of a number D. Math class method that will raise a number to a power E. Method of the Math class that returns the smaller of two numbers F. Math class constant that is the natural exponent

Computer Science & Information Technology

Bluetooth is used by laptops, tablets, and smartphones for device interfacing

Indicate whether the statement is true or false

Computer Science & Information Technology