1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <iostream> int main() { for (int i = 2; i <= 1000; i++) { std::cout << i << ','; int n = i; int k = 0; while (n != 1) { n = n % 2 ? n * 3 + 1 : n / 2; k++; } std::cout << k << '\n'; } return 0; }