Question: Write a basic recursive function that sums all numbers from 1 to n Please write a simple recursive method recursiveAdd ( ) that adds all

Write a basic recursive function that sums all numbers from 1 to n
Please write a simple recursive method recursiveAdd() that adds all integers between the 1 and the input number.
Your method should return the result as an integer.
In the event of a zero or negative input your method should return 0.
Remember, you must have a halting condition so that the recursive function doesn't hang the program.
Recursive functions are useful anytime you must use a previous result of the algorithm for the next iteration of the algorithm.
Solution
Reset
Java
Sample Test Case #1
10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!