#include <stdio.h> void printCollatz(int x) { while (x > 1) { if ((x % 2) == 0) { x = x / 2; } else { x = (3 * x) + 1; } } } int main() { int rangeValue = 12; for (int i = 1; i <= rangeValue; ++i) { printCollatz(i); } return 0; }
Standard input is empty
1 2, 1 3, 10, 5, 16, 8, 4, 2, 1 4, 2, 1 5, 16, 8, 4, 2, 1 6, 3, 10, 5, 16, 8, 4, 2, 1 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 8, 4, 2, 1 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 10, 5, 16, 8, 4, 2, 1 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 12, 6, 3, 10, 5, 16, 8, 4, 2, 1