NPTEL Programming Assignment: T1-Q2
For a number N, you have to do the following operations until you get to 1: if N is even, reduce the number to N/2 and If N is odd, then increase the number to (3*N)+1, and repeat the process till you get 1.
You have to output the number of odd numbers in the sequence of numbers you get in the above algorithm, including the number N (if N is odd) and the number 1.
3
3
The sequence of numbers starting from 3 is 3, 10, 5, 16, 8, 4, 2, 1. In this sequence, 3, 5 and 1 are odd.
11
5
5
2
1024
1
7
6