Question: What is wrong with the following method for calculating factorials? Calculates the factorial of a non-negative integer, that is, the product of all integers between

What is wrong with the following method for calculating factorials? Calculates the factorial of a non-negative integer, that is, the product of all integers between 1 and the given integer, inclusive. The worstTime(n) is O(n), where n is the given integer. @param n the non-negative integer whose factorial is calculated. @return the factorial of n. @throws IllegalArgumentException if n is less than 0. */ public static long factorial (int n) { if (n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
