%I #43 Mar 27 2022 18:01:13
%S 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,
%T 28,14,30,1,32,16,34,8,36,18,38,4,40,20,42,10,44,22,46,2,48,24,50,12,
%U 52,26,54,6,56,28,58,14,60,30,62,1,64
%N 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.
%C This is a fractal sequence because removing the first occurrence of each number in the sequence will leave the original sequence behind.
%C 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.
%C 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.
%H Antti Karttunen, <a href="/A322250/b322250.txt">Table of n, a(n) for n = 1..16384</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F a(n) = A000265(n)-1, unless A000265(n) = 1 in which case a(n) = 1.
%F a(n) = if n is 1 then 1, else if n is odd then n-1, else a(n/2).
%F a(n) = max(1, A153733(n-1)). - _Rémy Sigrist_, Dec 01 2018
%e 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.
%e 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.
%e 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.
%e 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.
%t 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 *)
%o (PARI) print_list(n)={my(i);for(i=1,n,print1(max(1,i>>valuation(i,2)-1),","));}
%o (PARI) a(n)={max(1, n>>valuation(n,2)-1)} \\ _Andrew Howroyd_, Dec 01 2018
%o (Python)
%o def print_list(n):
%o for i in range(1,n,2):
%o z=i
%o while z>1 and z%2 == 1:
%o z = (z-1)/2
%o print(z)
%o def a(n):
%o z = 2*n - 1
%o while z>1 and z%2 == 1:
%o z = (z-1)/2
%o print(z)
%o (Python)
%o def A322250(n):
%o s = bin(2*n-1)[2:].rstrip('1')
%o return int(s,2) if s != '' else 1 # _Chai Wah Wu_, Jan 02 2019
%Y Cf. A000265, A153733.
%K nonn,base
%O 1,3
%A _David Cleaver_, Nov 30 2018