login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(n) is the smallest number larger than a(n-1) that is not a partial sum of 2^a(1),2^a(2),...,2^a(n-1), with a(1)=0.
2

%I #22 Mar 24 2023 23:12:29

%S 0,2,3,6,7,10,11,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,

%T 31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,

%U 54,55,56,57,58,59,60,61,62,63,66,67

%N a(n) is the smallest number larger than a(n-1) that is not a partial sum of 2^a(1),2^a(2),...,2^a(n-1), with a(1)=0.

%C a(n) is the smallest number such that a(n)>a(n-1) and a(n)'s k-th binary digit is 1, for some k different from a(1),a(2),...,a(n-1).

%C The first 2^n-1 terms of A334992 are the nonzero partial sums of {2^a(1), 2^a(2), ..., 2^a(n)}.

%C 2^n is in the sequence if and only if n isn't in the sequence.

%C Let G(n) be the number of terms in the sequence among 0,1,2,..,n-1. Then G(2^n)=2^n-2^G(n).

%C G(n)/n seems to be 1-(1/n)^(1/log(n))^(1/loglog(n))^(1/logloglog(n))^... asymptotically (all logs are base 2).

%H Alon Heller, <a href="/A335033/b335033.txt">Table of n, a(n) for n = 1..65536</a>

%e a(2)=2 because 2 is the smallest number > 0 which isn't a partial sum of {1}={2^0}.

%e a(4)=6 because 6 is the smallest number > 3 which isn't a partial sum of {1,4,8}={2^0,2^2,2^3}.

%o (Python)

%o def gen():

%o """Generates the terms of A335033, starting with 1"""

%o A334992 = [0, 1]

%o A335033 = [0, 2]

%o yield 0

%o yield 2

%o power_index = 1

%o while True:

%o new_power = 2 ** A335033[power_index]

%o for i in range(len(A334992)):

%o A334992.append(A334992[i] + new_power)

%o for x in range(A334992[-2] + 1, A334992[-1]):

%o if A335033[-1] != x:

%o A335033.append(x)

%o yield x

%o power_index += 1

%o def A335033_list(n):

%o """Returns the n first elements as a list"""

%o g = gen()

%o return [next(g) for _ in range(n)]

%o print(A335033_list(20))

%Y Complement of A334992.

%K nonn,base,easy

%O 1,2

%A _Alon Heller_, May 20 2020