File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
main/java/com/thealgorithms/recursion
test/java/com/thealgorithms/recursion Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ private Factorial() {
2020 * @return factorial of n
2121 * @throws IllegalArgumentException if n is negative
2222 */
23-
23+
2424 public static long factorial (int n ) {
2525 if (n < 0 ) {
2626 throw new IllegalArgumentException ("Factorial is not defined for negative numbers." );
Original file line number Diff line number Diff line change @@ -10,24 +10,24 @@ public class FactorialTest {
1010 public void testFactorialOfZero () {
1111 assertEquals (1 , Factorial .factorial (0 ));
1212 }
13-
13+
1414 @ Test
1515 public void testFactorialOfOne () {
1616 assertEquals (1 , Factorial .factorial (1 ));
1717 }
18-
18+
1919 @ Test
2020 public void testFactorialOfPositiveNumbers () {
2121 assertEquals (120 , Factorial .factorial (5 ));
2222 assertEquals (720 , Factorial .factorial (6 ));
2323 assertEquals (5040 , Factorial .factorial (7 ));
2424 }
25-
25+
2626 @ Test
2727 public void testFactorialOfTen () {
2828 assertEquals (3628800 , Factorial .factorial (10 ));
2929 }
30-
30+
3131 @ Test
3232 public void testNegativeNumberThrowsException () {
3333 assertThrows (IllegalArgumentException .class , () -> Factorial .factorial (-1 ));
You can’t perform that action at this time.
0 commit comments