OFFSET
1,1
COMMENTS
The sequence is well defined:
- a(1) = 3,
- for n > 0, let k be such that 2^k + 1 + a(1) + ... + a(n) < 2^(k+1),
- then a(n+1) <= 2^k + 1.
The variant where we avoid powers of 3 corresponds to the positive even numbers (A299174).
LINKS
EXAMPLE
- 1 = 2^0, so 1 is not a term,
- 2 = 2^1, so 2 is not a term,
- a(1) = 3 (as 3 is not a power of 2),
- 4 = 2^2, so 4 is not a term,
- 3 + 5 = 2^3, so 5 is not a term,
- a(2) = 6 (as neither 6 nor 3 + 6 is a power of 2),
- 3 + 6 + 7 = 2^4, so 7 is not a term,
- 8 = 2^3, so 8 is not a term,
- a(3) = 9 (as none of 9, 3 + 9, 6 + 9, 3 + 6 + 9 is a power of 2).
PROG
(C#) See Links section.
(C++) See Links section.
(Python)
from math import gcd
from itertools import count, islice
def agen(): # generator of terms
a, ss, pows2, m = [], set(), {1, 2}, 2
for k in count(1):
if k in pows2: continue
elif k > m: m <<= 1; pows2.add(m)
if any(p2-k in ss for p2 in pows2): continue
a.append(k); yield k
ss |= {k} | {k+si for si in ss if k+si not in ss}
while m < max(ss): m <<= 1; pows2.add(m)
print(list(islice(agen(), 32))) # Michael S. Branicky, Jun 09 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, May 09 2022
STATUS
approved