Skip to content

Instantly share code, notes, and snippets.

@vipul43
Created July 20, 2020 10:20
Show Gist options
  • Save vipul43/b009ddc9be3e0b01023aeec1207dd221 to your computer and use it in GitHub Desktop.
Save vipul43/b009ddc9be3e0b01023aeec1207dd221 to your computer and use it in GitHub Desktop.
cses day1 problems solutions
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
void solution(){
ll n;
cin >> n;
cout << n << " ";
while(n!=1){
if(n%2==0){
n=n/2;
} else{
n=(n*3)+1;
}
cout << n << " ";
}
cout << "\n";
}
int main() {
int T=1;
// cin >> T;
for(int t=0; t<T; t++) {
solution();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment