Write a program RecursiveSum
that has a static method sumInts()
that returns the sum of all the value between 0 and n
, where n
is supplied to the method as a parameter.
In that static method, if n
is greater than 0 the method should return the value of n
added to the value of the sumInts
of all the values less than n (but greater than 0). If n = 0
(the base case), return a value of 0.
Your program should also have a static main()
method that demonstrates the recursive function sumInts()
.