/*
Recursion :
persistence(num) = 0 if num < 10
= [1 + persistence(multiplication of digits of num)] if num >= 10
*/intpersistence(intnum){// Given number is positive, so no need to check for negative numbers// if number is already single digit return 0if(num<10)return0;// get the multiplication of digitsintmul=1;while(num>0){mul*=(num%10);num/=10;}// return 1 + persistence(mul)return1+persistence(mul);}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
C++ solution