#K8021. Reduction Length Computation Using Collatz Process
Reduction Length Computation Using Collatz Process
Reduction Length Computation Using Collatz Process
Given an integer (n), compute the reduction length for each integer in the range (1) to (n) using the Collatz process. The transformation rules are as follows:
- If an integer (x) is even, then it becomes (\frac{x}{2}).
- If an integer (x) is odd, then it becomes (3x+1).
The reduction length of an integer is defined as the number of steps required for the value to become 1. For example, the reduction length for 1 is 0 because it is already 1.
Your task is to output a dictionary mapping each integer (i) (from (1) to (n)) to its corresponding reduction length. The output should follow the Python dictionary format.
inputFormat
A single integer (n) representing the upper bound of the range ([1, n]). Input is provided via standard input (stdin).
outputFormat
Print a dictionary (in Python dictionary format) that maps each integer from (1) to (n) to its computed reduction length. The output should be printed to standard output (stdout) as a single line.## sample
5
{1: 0, 2: 1, 3: 7, 4: 2, 5: 5}