(*********************************************************************

	Copyright 1989 by Roman E. Maeder
	
	Adapted from
	Roman E. Maeder: Programming in Mathematica, Addison-Wesley, 1989.

	Permission is hereby granted to make copies of this file for
	any purpose other than direct profit, or as part of a
	commercial product, provided this copyright notice is left
	intact.  Sale, other than for the cost of media, is prohibited.
	
	Permission is hereby granted to reproduce part or all of
	this file, provided that the source is acknowledged.

 *********************************************************************)


length[n_Integer?Positive] :=
	Block[{i=1, m=n}, While[m != 1, m = If[OddQ[m], 3m+1, m/2]; i++];i ]
length[_] = 0

max[low_] :=
	Block[{m=0, n=0, i=low, j},
		While[ True,
			j = length[i];
			If[j > m, m = j; n = i; Print["length[", n, "] = ", m] ];
			i++;
			If[ Mod[i, 100] == 0, Print["i = ", i] ]
		]
	]
