Skip to content

Commit 05f20f9

Browse files
Fix: remove main method and I/O for Factorial recursion
1 parent 3e7f6a3 commit 05f20f9

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed
Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package com.thealgorithms.recursion;
22

3-
import java.util.Scanner;
4-
53
/**
64
* This class provides a recursive implementation of the factorial function.
7-
* The factorial of a number n is defined as n! = n × (n-1) × (n-2) × ... × 1
8-
* with the base case 0! = 1.
95
*/
106
public class Factorial {
117

@@ -25,20 +21,4 @@ public static long factorial(int n) {
2521
}
2622
return n * factorial(n - 1);
2723
}
28-
29-
// Main method with user input
30-
public static void main(String[] args) {
31-
Scanner scanner = new Scanner(System.in);
32-
System.out.print("Enter a number to find its factorial: ");
33-
34-
int num = scanner.nextInt();
35-
scanner.close();
36-
37-
try {
38-
long result = factorial(num);
39-
System.out.println("Factorial of " + num + " is: " + result);
40-
} catch (IllegalArgumentException e) {
41-
System.out.println(e.getMessage());
42-
}
43-
}
4424
}

0 commit comments

Comments
 (0)