You are viewing a single comment's thread. Return to all comments →
Yeah, I was facing that issue too. What happens here is that, for both 18 and 19 the length is same. So store the value which occur later.
For both 18 and 19 it is 21.
So, when your code store for 18, then in the next iteration, store for 19. Use something like lenght >= max_length
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Project Euler #14: Longest Collatz sequence
You are viewing a single comment's thread. Return to all comments →
Yeah, I was facing that issue too. What happens here is that, for both 18 and 19 the length is same. So store the value which occur later.
For both 18 and 19 it is 21.
So, when your code store for 18, then in the next iteration, store for 19. Use something like lenght >= max_length