Class Factorial
java.lang.Object
topics.divideconquer.Factorial
DIVIDE AND CONQUER PROBLEM: CALCULATE THE FACTORIAL OF A NUMBER
- Author:
- vicegd
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Factorial
public Factorial()
-
-
Method Details
-
fact1
public int fact1(int n) This method iteratively calculates the factorial with a linear complexity O(n)- Parameters:
n- Number to calculate greater than or equal to 0- Returns:
- Factorial of the number
-
fact2
public int fact2(int n) This method recursively calculates the factorial with a linear complexity O(n), DandC by subtraction with a=1,b=1,k=0- Parameters:
n- Number to calculate greater than or equal to 0- Returns:
- Factorial of the number
-