A293576 Numbers n such that the set of exponents in expression for 2*n as a sum of distinct powers of 2 can be partitioned into two parts with equal sums.
0, 7, 13, 15, 22, 25, 27, 30, 39, 42, 45, 47, 49, 51, 54, 59, 60, 62, 75, 76, 82, 85, 87, 90, 93, 95, 97, 99, 102, 107, 108, 110, 117, 119, 120, 122, 125, 127, 141, 143, 147, 148, 153, 155, 158, 162, 165, 167, 170, 173, 175, 179, 180, 185, 187, 188, 190, 193
Offset: 1
Examples
2*42 = 2^6 + 2^4 + 2^2 and 6 = 4 + 2, hence 42 appears in the sequence. 2*11 = 2^4 + 2^2 + 2^1 and { 1, 2, 4 } cannot be partitioned into two parts with equals sums, hence 11 does not appear in the sequence.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..20000
Programs
-
Maple
b:= proc(n, t) option remember; `if`(n=0, is(t=0), (i-> b(n-2^i, t-i) or b(n-2^i, t+i))(ilog2(n))) end: a:= proc(n) option remember; local k; for k from 1+ `if`(n=1, -1, a(n-1)) while not b(2*k, 0) do od; k end: seq(a(n), n=1..100); # Alois P. Heinz, Oct 22 2017
-
PARI
is(n) = { my (v=Set(0)); my (b = Vecrev(binary(n))); for (i=1, #b, if (b[i], v = set union(Set(vector(#v, k, v[k]-i)), Set(vector(#v, k, v[k]+i))););); return (set search(v,0)); }
Comments