using System;
using System.Collections.Generic;
using System.Linq;
namespace A353889 {
///
/// Lexicographically earliest sequence of distinct positive integers with no finite subset summing to a power of 2.
///
class Program {
static void Main() {
HashSet sums = new HashSet();
sums.Add(0); // empty sum
long n = 0; // number of known values
long total = 0; // total of known values
long limit = 1; // power of two >= total + value to test
for (long v = 1; ; v++) {
while (limit < v + total) {
limit *= 2;
}
bool keep = true;
for (long powerOf2 = limit; powerOf2 >= v; powerOf2 /= 2) {
if (sums.Contains(powerOf2 - v)) {
keep = false;
break;
}
}
if (keep) {
total += v;
Console.WriteLine($"{++n} {v}");
if (n==40) {
break;
}
foreach (long s in sums.ToArray()) {
sums.Add(s + v);
}
}
}
}
}
}