- Select any whole number.
- If it is an even number, divide by 2; if it is odd number multiply by 3 and add 1.
- Repeat the process mentioned in step 2 until you get the loop value 4, 2, 1 in repetition.
Example
Whole number is 15.
15 is an odd no; so (15 × 3) + 1 = 46
46 is an even no; so 46 / 2 = 23
23 is an odd no; so (23 × 3) + 1 = 70
70 is an even no; so 70 / 2 = 35
35 is an odd no; so (35 × 3) + 1 = 106
106 is an even no; so 106 / 2 = 53
53 is an odd no; so (53 × 3) + 1 = 160
160 is an even no; so 160 / 2 = 80
80 is an even no; so 80 / 2 = 40
40 is an even no; so 40 / 2 = 20
20 is an even no; so 20 / 2 = 10
10 is an even no; so 10 / 2 = 5
5 is an odd no; so (5 × 3) + 1 = 16
16 is an even no; so 16 / 2 = 8
8 is an even no; so 8 / 2 = 4
4 is an even no; so 4 / 2 = 2
2 is an even no; so 2 / 2 = 1
1 is an odd no; so (1 × 3) + 1 = 4
4 is an even no; so 4 / 2 = 2
2 is an even no; so 2 / 2 = 1
So the loop 4..2..1 goes on and on.
Best Regards,
Bishwaranjan Barik
Bishwaranjan Barik
No comments:
Post a Comment