Solution
1068-Weird_Algorithm.cpp
1#include<bits/stdc++.h>
2using namespace std;
3#define int long long
4signed main(){
5 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
6 int n; cin>>n;
7 while(n>1){
8 cout<<n<<" ";
9 n=n&1?n*3+1:n>>1;
10 }
11 cout<<"1\n";
12 return 0;
13}Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.