c[n_?OddQ]  := 3n + 1     (* for n odd *)
c[n_?EvenQ] := n/2        (* for n even   *)

CollatzLength[n0_] :=
	Module[{n = n0, l = 1},
		While[ n != 1, n = c[n]; l = l + 1 ];
		l
	]

CollatzSequence[n0_] :=
	Module[{n = n0, l = {n0}},
		While[ n != 1, n = c[n]; l = Append[l, n] ];
		l
	]
