A357574 a(n) is the maximum number of pairs that sum to a power of 2 in a set of n consecutive odd numbers.
0, 1, 2, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 24, 26, 29, 31, 34, 36, 39, 41, 44, 46, 49, 51, 54, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 101, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 150, 153, 157, 160, 164, 167
Offset: 1
Keywords
Examples
a(5) = 5 because A357409(5) = 4, for which the corresponding set {-1, 1, 3, 5, 7} produces 5 powers of 2: 1+3, 1+7, 3+5, 3-1, 5-1.
Links
- Thomas Scheuerle, a(n+1) - a(n) for n = 1..500
- Max A. Alekseyev, On computing sets of integers with maximum number of pairs summing to powers of 2, arXiv:2303.02872 [math.CO], 2023.
Programs
-
MATLAB
function a = A357574( max_n ) a(1) = 0; q = []; for n = 1:max_n c = 0; for k = 0:n s = (2*([0:n]-k))+1; r = countpowtwo(s); if c < r c = r; q = s; end end a(n+1) = c; end end function c = countpowtwo(s) M = repmat(s, [length(s), 1]); M = M+M'; M(M<=0) = 7; M = bitand(M, M-1); M = M + eye(size(M)); c = length(find(M == 0))/2; end
Formula
a(n) <= A352178(n).
a(n) >= n-1. This would be the maximum value that could be attained for a set of only positive odd numbers and size n.
Extensions
Edited by Max Alekseyev, Mar 09 2023
Comments