Skip to content

Commit c2b8353

Browse files
style: mark Factorial class as final to satisfy Checkstyle
1 parent 3d0e6d0 commit c2b8353

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/com/thealgorithms/divideandconquer/Factorial.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package com.thealgorithms.divideandconquer;
2+
23
/**
34
* Computes the factorial of a non-negative integer using an iterative
45
* approach to avoid recursion overhead and stack overflow risks.
@@ -10,17 +11,19 @@
1011
* <p>Time Complexity: O(n)
1112
* <br>Space Complexity: O(1)
1213
*/
13-
public class Factorial {
14+
public final class Factorial {
15+
16+
private Factorial() {
17+
// Utility class
18+
}
19+
1420
/**
1521
* Returns the factorial of the given non-negative number.
1622
*
1723
* @param n the number to compute factorial for
1824
* @return factorial of n (n!)
1925
* @throws IllegalArgumentException if n is negative
2026
*/
21-
private Factorial() {
22-
// Utility class
23-
}
2427
public static long factorial(long n) {
2528
if (n < 0) {
2629
throw new IllegalArgumentException("Negative input not allowed");
@@ -34,3 +37,4 @@ public static long factorial(long n) {
3437
return result;
3538
}
3639
}
40+

0 commit comments

Comments
 (0)