fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5.  
  6. int main() {
  7. int n;
  8. cin >> n;
  9. while (n >= TEN) {
  10. int result = 1, copyN = n;
  11. while (copyN > 0) {
  12. int digit = copyN % TEN;
  13. result *= digit;
  14. copyN /= TEN;
  15. }
  16. n = result;
  17. }
  18. cout << n;
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5296KB
stdin
1234
stdout
8