USE JAVA PROGRAMMING 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...


USE JAVA PROGRAMMING


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 on the sum, repeating until a single integer digit is reached. The number of such cycles is that integer’s additive persistence.


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 digital root. The additive digital root of 1234 is 1.


The multiplicative persistence (http://mathworld.wolfram.com/MultiplicativePersistence.html ) and resulting multiplicative root are determined the same way, only multiplying the digits of an integer instead of adding.


For example


1. The beginning integer is 1234


2. The product of 1*2*3*4 = 24


3. The integer is now 24


4. The product of 2*4 = 8


5. The integer is now 8. When the value reaches a single digit, we are finished. This final integer is the multiplicative root. As before, the number of cycles is the multiplicative persistence. For 1234, the multiplicative persistence is 2, and its multiplicative root is 8.


Program Specifications The program should run as follows.


1) Ask the user for an integer.


2) If the given integer is a single digit, report it’s additive persistence and multiplicative persistence as 0 and both its additive and multiplicative \ root as itself.


3) If the integer is less than 0, that is a signal to quit the program.


4) Otherwise, find the additive/multiplicative persistence and additive/multiplicative root of the given integer and report the results to the user


5) Continue by prompting the user until they quit.



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here