Reply
Mon 24 Feb, 2014 01:28 pm
Read a positive integer value (validation), and compute the following sequence:
If the number is even, halve it;
If it is odd, multiply by 3 and add 1.
Repeat this process until the value is 1 or a negative number, printing out each value.
Finally print out how many of these operations you performed.
If the number ends at 1 print out that the number is a happy number.
If the number doesn't end at 1, print out that the number is a sad number.
Allow the user to enter another number if they want to see if it is a happy or sad number.
Ex.
enter number is 12
12
6
3
10
5
16
.
.
.
This is to be made using only looping