As per the title, I've been given this task to solve. While it is easy to do this using a traditional loop, I am still lost on how this could be achieved using recursion. Any help regarding this will be appreciated!
Here are the expected results:
Input: 4
Output: -2
Explanation: 1 -2 + 3 - 4 = -2
Input 9
Output: -3
Explanation: 1 - 2 + 3 - 4 + 5 - 6 + 7 - 8 + 9 = 5