OFFSET
0,3
LINKS
EXAMPLE
Sample iteration: 7->5->4->6->9->7 so a(7)=4.
Sample iteration: 12->18->27->20->30->45->34->51->... so a(12)=12.
MATHEMATICA
Table[Min[NestList[If[EvenQ[#], (3#)/2, Floor[(3#+2)/4]]&, n, 100]], {n, 0, 80}] (* Harvey P. Dale, May 02 2012 *)
PROG
(Perl) $|=1; for($n=1;; ++$n){ $m=$n; $d{$m}=$n, $m=f($m) while !$d{$m};
(Perl) if ($m<$n){ ($c, $m)=($d{$m}, $n); $d{$m}=$c, $m=f($m) while $m >= $n }
(Perl) print"$d{$n}, " } sub f { $_[0]%2 ? int((3*$_[0]+1)/4) : 3*$_[0]/2 }
(PARI) a(n)=local(m); if(n<=0, 0, m=n; while((m!=n=(3*n+n%2)\(2+n%2*2))&n<10^99, m=min(m, n)); m)
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
EXTENSIONS
More terms from Hugo van der Sanden
STATUS
approved