f(n)= n/2 if n is even, 3n+1 if n is odd; stop if n is 1.

EXAMPLE

E.g. orbit(3) = 3->10->5->16->8->4->2->1, so length of chain = 8

PROG

(ARIBAS): function a064685(maxarg: integer); var n: integer; begin for n := 1 to maxarg by 2 do write(length(orbit(n)), " "); end; end; a064685(140). For definition of function orbit see A064684.