#142EasyLoops· while Loops
Collatz Steps
Input format
`n`: a positive integer.
Output format
A list `[steps, peak]`.
Examples
Input: n = 6
Output: [8,16]
6, 3, 10, 5, 16, 8, 4, 2, 1: eight steps, and the highest value is 16.
Input: n = 1
Output: [0,1]
Already at 1: no steps, and the peak is 1.
Constraints
- 1 <= n <= 10^6
Study first
- #python
- #loops
- #while
- #sequences