Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

write a program that gets an integer value from the user and calculates the following: 1) additive persistence and the corresponding additive root 2) multiplicative persistence and the corresponding multiplicative root You will continue to do so until the user quits.

OpenStudy (anonymous):

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.

OpenStudy (anonymous):

Hint: use the modulo operator.

OpenStudy (anonymous):

which language is this ?

OpenStudy (anonymous):

how is it ?

OpenStudy (anonymous):

What?

OpenStudy (anonymous):

how can I apply it with different functions I got this big program but how can I generalize it n1=0 n2=0 n3=0 n4=0 s=0 n=int(input('input is your number:')) n1=n%10 n2=(n%100-n1)/10 n3=(n%1000-n%100)/100 n4=(n%10000-n%1000)/1000 s=n1+n2+n3+n4 p=n1*n2*n3*n4 if s%10==s: print('the sum of the digits is :',s,'and the additive persistence is:1') else: n1=s%10 n2=(s%100-n1)/10 n3=(s%1000-s%100)/100 n4=(s%10000-s%1000)/1000 s=n1+n2 p=n1*n2*n3 if p%100==s print('the product of the digits is :',p,'and the multiplicative persistence is:1')

OpenStudy (anonymous):

use loops

OpenStudy (anonymous):

how

OpenStudy (anonymous):

can u show me how @dust7

OpenStudy (turingtest):

I'm not sure I understand your problem specification, could you be more clear about it? - take input from user - if input is 1, return -else... (add digits?)

OpenStudy (anonymous):

ok I've don it thanks ..

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!