Saleh127

Untitled

May 8th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. ll a;
  7. cin>>a;
  8. printf("%lld",a);
  9. while(1)
  10. {
  11. if(a==1) {break; }
  12. else if(a%2)
  13. {
  14. a=a*3 +1;
  15. printf("% lld",a);
  16. }
  17. else
  18. {
  19. a=a/2;
  20. printf("% lld",a);
  21. }
  22. }
  23. cout<<endl;
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment