fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int c, n;
  6. cin>>c;
  7. cin>>n;
  8. for(int i=1;i<=n;++i) {
  9. if(c%2) {
  10. c=3*c+1;
  11. } else {
  12. c=c/2;
  13. }
  14. }
  15. cout<<c<<endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 16048KB
stdin
5 2
stdout
8