#### Problem

The problem basically states that if you do the following:

- take any positive integer
- if it's even, divide it by 2
- if it's odd, multiply it by 3 and add 1 to it
- repeat this and stop once you've gotten to 1

you will eventually stop at 1. Take 7 for example:

- 7 is odd so next number is 3(7) + 1, or 22
- 22 is even so next number is 22/2, or 11
- 11 is odd so next number is 3(11) + 1, or 34
- 34 is even so next number is 34/2, or 17
- 17 is odd so next number is 3(17) + 1, or 52
- 52 is even so next number is 52/2, or 26
- 26 is even so next number is 26/2, or 13
- 13 is odd so next number is 3(13) + 1, or 40
- 40 is even so next number is 40/2, or 20
- 20 is even so next number is 20/2, or 10
- 10 is even so next number is 10/2, or 5
- 5 is odd so next number is 3(5) + 1, or 16
- 16 is even so next number is 16/2, or 8
- 8 is even so next number is 8/2, or 4
- 4 is even so next number is 4/2, or 2
- 2 is even so next number is 2/2, or 1
- 1 is the stopping point

You can see that it bounces around a bit. What does that bouncing look like? Here are the paths for the numbers 2 to 31 (watch until at least 27):

Pretty cool that 27 seems to explode out of nowhere. How does the iterations required to get to 1 change based on the starting value?

And finally, what's the max value you get from each starting value?

## 0 comments:

## Post a Comment