Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 persistenceStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started