Programming Challenge 3: Odd and Even 2

Another Odd and Even challenge! Try to solve it! In this problem you will have take input a number. Then if the number is odd then divide it by 3 and if the number is even then divide it by 2. Do this until the number is 1 or less than 1. In the output print the number that how many steps it took to be 1.

For example, say the number is 10. It is even. So, we will divide it by 2. After dividing by 2 we get 5. Again, 5 is odd. So, we will divide it by 3. And then we get 1 (we will consider integer part only). It took two steps to get 1. So the output will be 2.


If you have any problem feel free to ask in comments !

0 comments :

Post a Comment

Spam comments will be deleted. :)

 
Loading...
TOP