first 7 Introductory problems

This commit is contained in:
2024-06-01 13:03:48 +02:00
parent d1fa3383f0
commit ca126c7a0a
8 changed files with 167 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
// Weird Algorithm
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
while (n != 1) {
cout << n << " ";
if (n & 1) {
n *= 3;
n++;
} else {
n /= 2;
}
}
cout << n << endl;
return 0;
}