Question: C++ problem please help. Thank you One such property is an integer's additive persistence and its resulting additive root (http://mathworld.wolfram.com/AdditivePersistence.html). Additive persistence is a property

C++ problem

C++ problem please help. Thank you One such property is an integer's

please help.

Thank you

One such property is an integer's additive persistence and its resulting additive root (http://mathworld.wolfram.com/AdditivePersistence.html). Additive persistence is a property of the sum of the digits of an integer. The sum of the digits is found, and then the summation of digits is performed creating a new sum. This process repeats until a single integer digit is reached. Consider the following example: 1. The beginning integer is 1234 2. Sum its digits is 1+2+3+4-10 3. The integer is now 10 4. The sum of its digits is 1 +0 1 5. The integer is 1. When the value reaches a single digit, we are finished. This final integer is the additive root The number of cycles is the additive persistence. The integer 1234 has an additive persistence of 2 (first sum was 10, then the second sum was 1). The final digit reached is called the integer's additive root. The additive digital root of 1234 is 1 Program Specifications The program should run as follows 1) Program takes in a single long from input, the number being checked a. if the input long is 0 or less, print the single work "Eiror" and end the program 2) Otherwise, the output should be two space separated longs a. the persistence b. the additive root 3) If the input long is a single digit, report its additive persistence as 0 and its additive root is the input number. 4) Otherwise calculate the additive persistence

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!