Class Factorial
java.lang.Object
topics.introduction.Factorial
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintfactorialOK(int n) Calculates the factorial of a number with a recursive algorithmintfactorialWrong(int n) Calculates the factorial of a number with a recursive algorithm It has a problem: if n is negative, it never stops
-
Constructor Details
-
Factorial
public Factorial()
-
-
Method Details
-
factorialOK
public int factorialOK(int n) Calculates the factorial of a number with a recursive algorithm- Parameters:
n- Value used to calculate the factorial- Returns:
- Factorial of n
-
factorialWrong
public int factorialWrong(int n) Calculates the factorial of a number with a recursive algorithm It has a problem: if n is negative, it never stops- Parameters:
n- Value used to calculate the factorial- Returns:
- Factorial of n
-