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.
LINKS
FORMULA
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
KEYWORD
nonn,base
AUTHOR
David Cleaver, Nov 30 2018
STATUS
approved