File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/main/java/com/thealgorithms/recursion Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 11package com .thealgorithms .recursion ;
22
33/**
4- * This class provides a recursive implementation of the factorial function.
4+ * Implementation of factorial using recursion.
5+ * <p>
6+ * The factorial of a non-negative integer n is defined as:
7+ * n! = n × (n-1) × (n-2) × ... × 1, with 0! = 1.
58 */
6- public class Factorial {
9+ public final class Factorial {
10+
11+ // Private constructor to prevent instantiation
12+ private Factorial () {
13+ throw new UnsupportedOperationException ("Utility class" );
14+ }
715
816 /**
9- * Recursive method to calculate factorial.
17+ * Calculates factorial recursively .
1018 *
11- * @param n the number to find factorial of
19+ * @param n non-negative integer
1220 * @return factorial of n
1321 * @throws IllegalArgumentException if n is negative
1422 */
You can’t perform that action at this time.
0 commit comments