1. Learn
  2. /
  3. Courses
  4. /
  5. Input/Output and Streams in Java

Connected

Exercise

Recursive sum calculation

Recursion helps solve problems by breaking them down into smaller, more manageable subproblems. In this exercise, you will implement a recursive method to compute the sum of numbers from 1 to n.

Instructions

100 XP
  • Add the base case, when the input n equals 1.
  • Call the method.
  • Start the first recursive call.