I am trying to find the multiplicative digital root MDR and multiplicative persistence MR of a given input value. For this, I have to use three functions MDR- to find the multiplicative digital root MPersistence - to find multiplicative persistence prodDigits - to find the product of digits of the input number. I have used the if-else block to give a recursive call to prodDigits function. But it only runs twice. For example if I give input 86, It should run as 86 -> 48 -> 32 -> 6 (MDR 6, Mpersistence 3) But my code only gives the output till 32 and persistence as 1
The output is
How can I fix this?


Aucun commentaire:
Enregistrer un commentaire