Step-by-step solution for Additive Persistence

View the challenge

This challenge requires you to continually add up all the numbers in the parameter until you reach a single number. For example, if the input is 2718, then you add up 2 + 7 + 1 + 8 = 18. You then do the same for 18, 1 + 8 = 9. When you reach a single number your program should return how many times you had to add to reach it. For 2718, your program should return **2**. We'll solve this problem by recursively adding up the numbers in the input.

You need to be a member to see the rest of this solution and code.