OFFSET
1,3
COMMENTS
If the Collatz conjecture is true, then this sequence contains every nonnegative integers.
LINKS
EXAMPLE
A319303(18) = 80, hence a(80) = 18.
MATHEMATICA
a[n0_] := Module[{n=n0, v=0}, While[n>1, t = If[OddQ[n], 3n+1, n/2]; If[t>4 && Mod[t+2, 6] == 0, v *= 2; v += Mod[n, 2]]; n = t; v++]; v]
Array[a, 50] (* Jean-François Alcover, Dec 18 2018, translated from PARI *)
PROG
(PARI) a(n) = my (v=0); while (n>1, my (t=if (n%2, 3*n+1, n/2)); if (t>4 && (t+2)%6==0, v*=2; v+=n%2); n=t; v++); v
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Dec 13 2018
STATUS
approved