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.

A339597 When 2*n+1 first appears in A086799.

Original entry on oeis.org

1, 2, 5, 4, 9, 10, 13, 8, 17, 18, 21, 20, 25, 26, 29, 16, 33, 34, 37, 36, 41, 42, 45, 40, 49, 50, 53, 52, 57, 58, 61, 32, 65, 66, 69, 68, 73, 74, 77, 72, 81, 82, 85, 84, 89, 90, 93, 80, 97, 98, 101, 100, 105, 106, 109, 104, 113, 114, 117, 116, 121, 122, 125, 64, 129, 130, 133, 132, 137
Offset: 0

Views

Author

Marc LeBrun and N. J. A. Sloane, Jan 06 2021

Keywords

Crossrefs

Cf. A086799, A091072 (terms sorted), A129760.

Programs

  • Maple
    N := 127: # for a(0) to a(N)
    V := Array(0..N): count := 0:
    for i from 1 while count < N+1 do
      with(MmaTranslator[Mma]):
      f(i) := BitOr(i,i-1);
      v := (f(i)-1)/2;
      if v <= N and V[v] = 0 then count := count+1; V[v] := i fi
    od:
    convert(V,list); # Robert Israel, Jan 07 2021
  • PARI
    f(n) = bitor(n, n-1); \\ A086799
    a(n) = my(k=1); while (f(k) != 2*n+1, k++); k; \\ Michel Marcus, Jan 07 2021
    
  • PARI
    a(n) = n++; n<<1 - 1<Kevin Ryde, Mar 29 2021
    
  • Python
    def A339597(n): return ((m:=n+1)<<1)-(m&-m) # Chai Wah Wu, Sep 01 2023

Formula

a(n) = 2*(n+1) - A006519(n+1) = n+1 with a 0 bit inserted above its least significant 1-bit. - Kevin Ryde, Mar 29 2021
a(n) = A129760(n+1) + n+1. - Christian Krause, May 05 2021