What's the output of the following code segment?
public static void main(String[] args) {
factorial(4);
}
public static int factorial(int n) {
if(n <= 1) {
System.out.println(n);
return 1;
} else {
int res = n * factorial(n - 1);
System.out.println(res);
return res;
}
}
What's the output of the following code segment? public static void main(String[] args) { factorial(4); } public sta
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What's the output of the following code segment? public static void main(String[] args) { factorial(4); } public sta
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!