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.

A322250 Take binary expansion of 2n-1 and delete the trailing block of 1's, except if the number is 11...1, leave a single 1.

Original entry on oeis.org

1, 1, 2, 1, 4, 2, 6, 1, 8, 4, 10, 2, 12, 6, 14, 1, 16, 8, 18, 4, 20, 10, 22, 2, 24, 12, 26, 6, 28, 14, 30, 1, 32, 16, 34, 8, 36, 18, 38, 4, 40, 20, 42, 10, 44, 22, 46, 2, 48, 24, 50, 12, 52, 26, 54, 6, 56, 28, 58, 14, 60, 30, 62, 1, 64
Offset: 1

Views

Author

David Cleaver, Nov 30 2018

Keywords

Comments

This is a fractal sequence because removing the first occurrence of each number in the sequence will leave the original sequence behind.
One can repeat this process and always get back the original sequence, i.e., this sequence contains itself an infinite number of times. This is equivalent to removing the odd-indexed entries and getting back the original sequence.
Fractal sequence listing the smallest positive ancestor of the odd positive integers, where ancestor(n) = (n-1)/2 if n>1 is odd or n if n is 1 or even.

Examples

			a(3) = 2 because the 3rd odd integer 5 equals 101 in binary, and removing the least significant consecutive 1's gives us 10 in binary = 2 in decimal.
a(4) = 1 because the 4th odd integer 7 equals 111 in binary, and removing all except the initial 1 gives us 1 in binary = 1 in decimal.
a(5) = 4 because the 5th odd integer 9 equals 1001 in binary, and removing the least significant consecutive 1's gives us 100 in binary = 4 in decimal.
a(6) = 2 because the 6th odd integer 11 equals 1011 in binary, and removing the least significant consecutive 1's gives us 10 in binary = 2 in decimal.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := n/2^IntegerExponent[n, 2]; a[n_] := Module[{f1=f[n]}, If[f1==1, 1, f1-1]]; Array[a, 60] (* Amiram Eldar, Dec 01 2018 *)
  • PARI
    print_list(n)={my(i);for(i=1,n,print1(max(1,i>>valuation(i,2)-1),","));}
    
  • PARI
    a(n)={max(1, n>>valuation(n,2)-1)} \\ Andrew Howroyd, Dec 01 2018
    
  • Python
    def print_list(n):
      for i in range(1,n,2):
        z=i
        while z>1 and z%2 == 1:
          z = (z-1)/2
        print(z)
    def a(n):
      z = 2*n - 1
      while z>1 and z%2 == 1:
        z = (z-1)/2
      print(z)
    
  • Python
    def A322250(n):
        s = bin(2*n-1)[2:].rstrip('1')
        return int(s,2) if s != '' else 1 # Chai Wah Wu, Jan 02 2019

Formula

a(n) = A000265(n)-1, unless A000265(n) = 1 in which case a(n) = 1.
a(n) = if n is 1 then 1, else if n is odd then n-1, else a(n/2).
a(n) = max(1, A153733(n-1)). - Rémy Sigrist, Dec 01 2018