Cycle Length of Syracuse Sequence

  1. Consider the Syracuse Sequence defined in a previous exercise.
  2. Given the input 22, the following sequence of numbers will be printed
  3. The number of numbers printed (including the 1) is called the cycle length of a given input n.
  4. Design a program which requests the user to input an integer n, and then calculate the cycle length of 1, 2, 3, ..., n as follows.


Input a number -- 22
1:1
2:2
3:8
4:3
5:6
6:9
7:17
8:4
9:20
10:7
11:15
12:10
13:10
14:18
15:18
16:5
17:13
18:21
19:21
20:8
21:8
22:16