The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.
대충 보니깐
짝수일땐 나누고 홀수일땐 3배수 + 1 해서 쭈우욱 계산하고 1이 될때까지 계산을 하는거 같은데
하필 백만 단위임 ㅡ.,ㅡ
이건 뭐 어떤식으로 생각을 해야될까
손수 하나하나 다 할려면 좀 빡칠꺼 같은데......
백만대면 저 짓을 천만번 가까이 해야되자나
흠.. 뭐 좋은 수 없을려나