ARTICLE AD BOX
public class Main {
public static int sum(int start, int end) {
if (end > start) {
return end + sum(start, end - 1);
} else {
return end;
}
}
public static void main(String[] args) {
int result = sum(1, 10);
System.out.println(result);
}
This post is hidden. It was deleted 11 hours ago by Progman, David, miken32.
Closed. This question needs details or clarity. It is not currently accepting answers.
Edit the question to add relevant details and clarify your question. Adding more specific information will help others understand your issue and provide a better answer. If edited, your question will be reviewed and might be reopened.
Closed 14 hours ago.
public class Main { public static int sum(int start, int end) { if (end > start) { return end + sum(start, end - 1); } else { return end; } } public static void main(String[] args) { int result = sum(1, 10); System.out.println(result); } }Can someone help me with this? I'm genuinely getting confused here, especially in a return end + sum(start, end - 1);. I want to know how this recursion works
