fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int p(int x) {
  5. int t = 1;
  6. while (x != 0) {
  7. t *= x % 10;
  8. x = x / 10;
  9. }
  10. return t;
  11. }
  12.  
  13. int main() {
  14. int x;
  15. while (cin >> x) {
  16. int i = 0;
  17. while (x / 10 != 0) {
  18. x = p(x);
  19. i++;
  20. }
  21. cout << i << endl;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 15232KB
stdin
2356951
53
9892
stdout
2
2
3