next[n_Integer] := If[EvenQ@n, Floor[Sqrt[n]], Floor[n^(3/2)]] stats[n_Integer] := Block[{data = Most@NestWhileList[next, n, # > 1 &], mx}, mx = First@Ordering[data, -1]; {n, Length[data], data[[mx]], mx - 1}] {TableForm[Table[stats@n, {n, 20, 39}], TableHeadings -> {None, {"n", "length", "max", "max pos"}}]