Assignment Overview

The aim of this project is practice the use of while loops and conditionals statements. You are going to write a program that prompts the user for an integer and then determines the additive persistence and corresponding additive root, and the multiplicative persistence, the corresponding multiplicative digital root of that integer. You will continue to do so until the user quits


There are many properties of numbers that one can investigate. The ancient Greeks were fascinated with the properties of integers, even ascribing them mystical properties.

One such property is an integers additive persistence and its resulting additive root ( ). 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 integers 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 integers additive digital root. The additive digital root of 1234 is 1.

The multiplicative persistence

( ) 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 its 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.

Getting Started

1)Create the proj02 as usual.

2)Break the problem down into parts. Some obvious parts:

a.gather input from the user, and check for negative numbers (the quit condition)

b.write a loop around the queries that can do the queries until the stop condition is reached

c.write a loop that can sum the digits of an integer until it reaches a single digit.

d.write a loop that can take the produce of the digits of an integer until it reaches a single digit, using the above approach

e.Get the whole thing to work with one or the other (additive, multiplicative) before you address the other

3)How do you get the digits of an integer? Look at a combination of division (/) and remainder(%) operators on integers. Try it out in idle first

4)I would add some diagnostic output so you can be sure things are working as they should. For each pass through the loop of the additive (or multiplicative) persistence, print each new integer created

Example Output

Note that the first two cycles demonstrate the use of diagnostic output (see (4) under Getting Started). Your final program should not print out such diagnostic output. see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.