cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A087230 a(n) is the 2-adic valuation of 6*n + 4.

Original entry on oeis.org

2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 8, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1
Offset: 0

Views

Author

Labos Elemer, Aug 28 2003

Keywords

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)
...
where values n in the odd strand (1,6,26,106,426,...) equal sequence A020989, and values n in the even strand (0,2,10,42,170,...) equal sequence A020988. (End)

Examples

			n=85: m = 6*85+4 = 514 and Collatz-iteration goes on by one dividing step, a(85)=1.
		

Crossrefs

Programs

  • 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 *)
  • PARI
    forstep(n=0, 1000, 1, m=6*n+4; print1(valuation(m, 2), ", ") ) \\ K. G. Stier, Aug 19 2014
    
  • 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
  • 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
    

Formula

a(n) = A007814(A016957(n)). - Michel Marcus, Jan 27 2022
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 2. - Amiram Eldar, Sep 10 2024

Extensions

a(0) = 2 prepended by Andrey Zabolotskiy, Jan 27 2022, based on Ihar Senkevich's contribution