Challenge for Basic Recursion


You will be given a positive integer a. Fill in the method doStuff so that it adds up all the positive integers up to a and returns the sum. For example, when given 4 it should return 10 (4+3+2+1).

While there are other ways to solve this challenge, you should use recursion to get the sum.

(Raw Input Note: The first line contains N, the number of cases, and N lines follow, which each contain a single integer.)

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Contact Us
Sign in or email us at [email protected]