25 lines
543 B
C++
25 lines
543 B
C++
#include <iostream>
|
|
#include <string>
|
|
|
|
// TODO:
|
|
// Use GMP for numbers (to allow for really big numbers)
|
|
// Make disproving mode
|
|
// Make no print mode (for speed, implement after disproving mode)
|
|
|
|
int main(int argc, char* argv[]) {
|
|
// If number not provided
|
|
if (argc < 2) {
|
|
std::cout << "Usage: " << argv[0] << " <number>\n";
|
|
exit(1);
|
|
}
|
|
long long x { std::stoll(argv[1]) };
|
|
std::cout << x << '\n';
|
|
while (x != 1) {
|
|
if (x % 2 == 0)
|
|
x /= 2;
|
|
else if (x % 2)
|
|
x = x*3+1;
|
|
std::cout << x << '\n';
|
|
}
|
|
}
|