It turns out this is a really hard question to answer in general. The Collatz conjecture is that no matter what the initial condition is, the function will eventually produce 1 as an output. This is an open problem in mathematics: nobody knows the answer.