1. 学ぶ
  2. /
  3. コース
  4. /
  5. Input/Output and Streams in Java

Connected

演習

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.

指示

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