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.

Showing 1-3 of 3 results.

A096111 If n = 2^k - 1, then a(n) = k+1, otherwise a(n) = (A000523(n)+1)*a(A053645(n)).

Original entry on oeis.org

1, 2, 2, 3, 3, 6, 6, 4, 4, 8, 8, 12, 12, 24, 24, 5, 5, 10, 10, 15, 15, 30, 30, 20, 20, 40, 40, 60, 60, 120, 120, 6, 6, 12, 12, 18, 18, 36, 36, 24, 24, 48, 48, 72, 72, 144, 144, 30, 30, 60, 60, 90, 90, 180, 180, 120, 120, 240, 240, 360, 360, 720, 720, 7, 7, 14, 14, 21, 21
Offset: 0

Views

Author

Amarnath Murthy, Jun 29 2004

Keywords

Comments

Each n > 1 occurs 2*A045778(n) times in the sequence.
f(n+2^k) = (k+1)*f(n) if 2^k > n+1. - Robert Israel, Apr 25 2016
If the binary indices of n (row n of A048793) are the positions 1's in its reversed binary expansion, then a(n) is the product of all binary indices of n + 1. The number of binary indices of n is A000120(n), their sum is A029931(n), and their average is A326699(n)/A326700(n). - Gus Wiseman, Jul 27 2019

Crossrefs

Permutation of A096115, i.e. a(n) = A096115(A122198(n+1)) [Note the different starting offsets]. Bisection: A121663. Cf. A096113, A052330.
Cf. A029931.

Programs

  • Maple
    f:= proc(n) local L;
        L:= convert(2*n+2,base,2);
        convert(subs(0=NULL,zip(`*`,L, [$0..nops(L)-1])),`*`);
    end proc:
    map(f, [$0..100]); # Robert Israel, Apr 25 2016
  • Mathematica
    CoefficientList[(Product[1 + k x^(2^(k - 1)), {k, 7}] - 1)/x, x] (* Michael De Vlieger, Apr 08 2016 *)
    bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];Table[Times@@bpe[n+1],{n,0,100}] (* Gus Wiseman, Jul 26 2019 *)
  • PARI
    N=166; q='q+O('q^N);
    gf= (prod(n=1,1+ceil(log(N)/log(2)), 1+n*q^(2^(n-1)) ) - 1) / q;
    Vec(gf)
    /* Joerg Arndt, Oct 06 2012 */
  • Scheme
    (define (A096111 n) (cond ((pow2? (+ n 1)) (+ 2 (A000523 n))) (else (* (+ 1 (A000523 n)) (A096111 (A053645 n))))))
    (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1)))))
    

Formula

G.f.: ( prod(k>=1, 1+k*x^(2^(k-1)) )- 1 ) / x. - Vladeta Jovovic, Nov 08 2005
a(n) is the product of the exponents in the binary expansion of 2*n + 2. - Peter Kagey, Apr 24 2016

Extensions

Edited, extended and Scheme code added by Antti Karttunen, Aug 25 2006

A122155 Simple involution of natural numbers: List each block of (2^k)-1 numbers (from (2^k)+1 to 2^(k+1) - 1) in reverse order and fix the powers of 2.

Original entry on oeis.org

0, 1, 2, 3, 4, 7, 6, 5, 8, 15, 14, 13, 12, 11, 10, 9, 16, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 32, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 64, 127, 126, 125, 124, 123
Offset: 0

Views

Author

Antti Karttunen, Aug 25 2006

Keywords

Comments

From Kevin Ryde, Dec 29 2020: (Start)
a(n) is n with an 0<->1 complement applied to each bit between, but not including, the most significant and least significant 1-bits. Dijkstra uses this form and calls the complemented bits the "internal" digits.
The fixed points a(n)=n are n=0 and n=A029744. These are n=2^k by construction, and the middle of each reversed block is n=3*2^k. In terms of bit complement, these n have nothing between their highest and lowest 1-bits.
(End)

Examples

			From _Kevin Ryde_, Dec 29 2020: (Start)
  n    = 4, 5, 6, 7, 8
  a(n) = 4, 7, 6, 5, 8  between powers of 2
             <----      block reverse
Or a single term by bits,
  n    = 236 = binary 11101100
  a(n) = 148 = binary 10010100  complement between
                       ^^^^     high and low 1's
(End)
		

Crossrefs

Cf. A029744 (fixed points), A334045 (complement high/low 1's too), A057889 (bit reversal).

Programs

  • Mathematica
    Array[(1 + Boole[#1 - #2 != 0]) #2 - #1 + #2 & @@ {#, 2^(IntegerLength[#, 2] - 1)} &, 69] (* Michael De Vlieger, Jan 01 2023 *)
  • PARI
    a(n) = bitxor(n,if(n,max(0, 1<Kevin Ryde, Dec 29 2020
    
  • Python
    def A122155(n): return int(('1'if (m:=len(s:=bin(n)[2:])-(n&-n).bit_length())>0 else '')+''.join(str(int(d)^1) for d in s[1:m])+s[m:],2) if n else 0 # Chai Wah Wu, May 19 2023
    
  • Python
    def A122155(n): return n^((1<Chai Wah Wu, Mar 10 2025
  • R
    maxblock <- 5 # by choice
    a <- 1
    for(m in 1:maxblock){
                          a[2^m    ] <- 2^m
      for(k in 1:(2^m-1)) a[2^m + k] <- 2^(m+1) - k
    }
    (a <- c(0,a))
    # Yosu Yurramendi, Mar 18 2021
    
  • Scheme
    (define (A122155 n) (cond ((< n 1) n) ((pow2? n) n) (else (- (* 2 (A053644 n)) (A053645 n)))))
    (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1)))))
    

Formula

a(0) = 0; if n=2^k, a(n) = n; if n=2^k + i (with i > 0 and i < 2^k) a(n) = 2^(k+1) - i = 2*A053644(n) - A053645(n).
A002487(a(n)) = A002487(n), n >= 0 [Dijkstra]. - Yosu Yurramendi, Mar 18 2021

A122199 Permutation of natural numbers: a recursed variant of A122155.

Original entry on oeis.org

0, 1, 2, 3, 4, 7, 6, 5, 8, 13, 14, 15, 12, 11, 10, 9, 16, 25, 26, 27, 28, 31, 30, 29, 24, 21, 22, 23, 20, 19, 18, 17, 32, 49, 50, 51, 52, 55, 54, 53, 56, 61, 62, 63, 60, 59, 58, 57, 48, 41, 42, 43, 44, 47, 46, 45, 40, 37, 38, 39, 36, 35, 34, 33, 64, 97, 98, 99, 100, 103, 102
Offset: 0

Views

Author

Antti Karttunen, Aug 25 2006

Keywords

Comments

Maps between A096111 and A096115.

Crossrefs

Programs

Formula

a(0)=0, otherwise a(n) = A053644(A122155(n)) + a(A053645(A122155(n))).
Showing 1-3 of 3 results.