Question: Write a recursive function that receives a number and adds up all its digits in stages until all they have been added up to 1

Write a recursive function that receives a number and adds up all its digits in stages until all they have been added up to 1 digit and return this number:

For Example adddigits(n)

It recursively calls itself three times for input 123457

123457 -> 18 -> 9

123457 it adds 1+2+3+4+5+7 = 18

Then it receives 18 it adds up 1+8 = 9

C++ Programming

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!