OFFSET
1,2
COMMENTS
LINKS
T. D. Noe, Table of n, a(n) for n = 1..5000
EXAMPLE
a(4) = 5 because 7 is the fourth odd number and 5 iterations are needed: R(R(R(R(R(7)))))=1.
MATHEMATICA
nextOddK[n_] := Module[{m=3n+1}, While[EvenQ[m], m=m/2]; m]; (* assumes odd n *) Table[m=n; cnt=0; If[n>1, While[m=nextOddK[m]; cnt++; m!=1]]; cnt, {n, 1, 200, 2}]
PROG
(Haskell)
a075680 n = snd $ until ((== 1) . fst)
(\(x, i) -> (a000265 (3 * x + 1), i + 1)) (2 * n - 1, 0)
-- Reinhard Zumkeller, Jan 08 2014
(Perl)
sub a {
my $v = 2 * shift() - 1;
my $c = 0;
until (1 == $v) {
$v = 3 * $v + 1;
$v /= 2 until ($v & 1);
$c += 1;
}
return $c;
} # Ruud H.G. van Tol, Nov 16 2021
(PARI) a(n)=my(s); n+=n-1; while(n>1, n+=n>>1+1; if(n%2==0, n>>=valuation(n, 2)); s++); s \\ Charles R Greathouse IV, Dec 22 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
T. D. Noe, Sep 25 2002
STATUS
approved