login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
2
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,3
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.
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
EXAMPLE
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.
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 *)
PROG
(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
CROSSREFS
Sequence in context: A306408 A232626 A375124 * A175542 A076686 A114810
KEYWORD
nonn,base
AUTHOR
David Cleaver, Nov 30 2018
STATUS
approved