fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string f(string x) {
  6. int mult = 1;
  7. for (int i = 0; i < x.length(); i++) {
  8. mult *= int(x.at(i)) - int('0');
  9. }
  10. string result = to_string(mult);
  11. return result;
  12. }
  13.  
  14. int main() {
  15. string inp;
  16. while (cin >> inp) {
  17. int count = 0;
  18. while (inp.length() > 1) {
  19. inp = f(inp);
  20. count++;
  21. }
  22. cout << count << endl;
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty