Use FixedPointList?

This is my code:

f[n_Integer] := If[ EvenQ[n] , f[n/2] , f[3 n + 1] ]

f[1] := 1

FixedPointList[f,6]

FixedPointList should give me {6,3,10,5,16,8,4,2,1,1}, but instead I’m only getting {6,1,1}

You are doing a double recursion here: your function is recursive and FixedPointList itself generates recursion. Here is what you want, I believe, for your Collatz Problem. Notice that you better specify a non-standard SameTest because otherwise you are going to get into an infinite loop as the values cycle over 4, 2, 1. I also stuck in the number 1000 to protect against the program going wild.

 f[n_Integer] := If[EvenQ[n], n/2, 3 n + 1]
 
 FixedPointList[f, 6, 1000, SameTest -> (#2 == 1 &)]

You are doing a double recursion here: your function is recursive and FixedPointList itself generates recursion.

thank you this was very helpful!