OFFSET
0,1
COMMENTS
In Collatz-algorithm if initiated with m=odd value, the first 3x+1 step is followed by a(n) step corresponding to division by 2. Compare to A085058 and A087229. Each 2nd term is either =1 or equals corresponding term of A087229, depending on whether the odd number congruent to 1 or 3 modulo 4.
From K. G. Stier, Aug 19 2014: (Start)
Sequence exhibits a "pseudo" ruler function (A001511) behavior. It is similar to the latter in repeating equal terms m>0 after each 2^m steps. However, the first occurrence of m in the mentioned ruler function is simply at n=log_2(m), while in the given sequence this property develops two distinct (odd and even) strands:
First occurrence of
m=1 at a(1); m=2 at a(0)
m=3 at a(6); m=4 at a(2)
m=5 at a(26); m=6 at a(10)
m=7 at a(106); m=8 at a(42)
m=9 at a(426); m=10 at a(170)
...
LINKS
Kenny Lau, Table of n, a(n) for n = 0..10000
FORMULA
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 2. - Amiram Eldar, Sep 10 2024
EXAMPLE
n=85: m = 6*85+4 = 514 and Collatz-iteration goes on by one dividing step, a(85)=1.
MAPLE
a:= n-> padic[ordp](6*n+4, 2):
seq(a(n), n=0..120); # Alois P. Heinz, Mar 16 2021
MATHEMATICA
Table[Part[Part[FactorInteger[6*w+4], 1], 2], {w, 0, 100}]
Table[IntegerExponent[6*n + 4, 2], {n, 0, 100}] (* Amiram Eldar, Jan 27 2022 *)
PROG
(PARI) forstep(n=0, 1000, 1, m=6*n+4; print1(valuation(m, 2), ", ") ) \\ K. G. Stier, Aug 19 2014
(Python)
n=100; N=3*n+2; val=[1]*(N+1); exp=2
while exp <= N:
for j in range(exp, N+1, exp): val[j] += 1
exp *= 2
for i in range(n+1): print(i, val[3*i+2])
# Kenny Lau, Jun 09 2018
(Python)
def A087230(n): return (~(m:=6*n+4) & m-1).bit_length() # Chai Wah Wu, Jul 02 2022
(Perl)
sub a {
my $nv= ((shift() << 1) | 1);
my $bp= 1;
while (($nv & 1) xor ($nv & 2)) {
$nv>>= 1;
$bp++;
}
return $bp;
} # Ruud H.G. van Tol, Nov 16 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Labos Elemer, Aug 28 2003
EXTENSIONS
a(0) = 2 prepended by Andrey Zabolotskiy, Jan 27 2022, based on Ihar Senkevich's contribution
STATUS
approved