A126684 Union of A000695 and 2*A000695.
0, 1, 2, 4, 5, 8, 10, 16, 17, 20, 21, 32, 34, 40, 42, 64, 65, 68, 69, 80, 81, 84, 85, 128, 130, 136, 138, 160, 162, 168, 170, 256, 257, 260, 261, 272, 273, 276, 277, 320, 321, 324, 325, 336, 337, 340, 341, 512, 514, 520, 522, 544, 546, 552, 554, 640, 642, 648, 650
Offset: 1
Examples
All nonnegative integers can be represented in the form b_i + b_j; e.g. 6 = 5+1, 7 = 5+2, 8 = 0+8, 9 = 4+5
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
- David Eppstein, Making Change in 2048, arXiv:1804.07396 [cs.DM], 2018.
Programs
-
Haskell
a126684 n = a126684_list !! (n-1) a126684_list = tail $ m a000695_list $ map (* 2) a000695_list where m xs'@(x:xs) ys'@(y:ys) | x < y = x : m xs ys' | otherwise = y : m xs' ys -- Reinhard Zumkeller, Dec 03 2011
-
Mathematica
nmax = 100; b[n_] := FromDigits[IntegerDigits[n, 2], 4]; Union[A000695 = b /@ Range[0, nmax], 2 A000695][[1 ;; nmax+1]] (* Jean-François Alcover, Oct 28 2019 *)
-
PARI
for(n=0,350,b=binary(n); l=length(b); if(sum(i=1,floor(l/2), component(b,2*i))==0,print1(n,",")))
-
Python
from gmpy2 import digits def A126684(n): def bisection(f,kmin=0,kmax=1): while f(kmax) > kmax: kmax <<= 1 while kmax-kmin > 1: kmid = kmax+kmin>>1 if f(kmid) <= kmid: kmax = kmid else: kmin = kmid return kmax def g(x): s = digits(x,4) for i in range(l:=len(s)): if s[i]>'1': break else: return int(s,2) return int(s[:i]+'1'*(l-i),2) def f(x): return n-1+x-g(x)-g(x>>1) return bisection(f,n-1,n-1) # Chai Wah Wu, Oct 29 2024
Formula
G.f.: sum(i>=1, T(i, x) + U(i, x) ), where
T := (k,x) -> x^(2^k-1)*V(k,x);
U := (k,x) -> 2*x^(3*2^(k-1)-1)*V(k,x); and
V := (k,x) -> (1-x^(2^(k-1)))*(4^(k-1) + sum(4^j*x^(2^j)/(1+x^(2^j)), j = 0..k-2))/(1-x);
Generating function. Define V(k) := [4^(k-1) + Sum ( j=0 to k-2, 4^j * x^(2^j)/(1+x^(2^j)) )] * (1-x^(2^(k-1)))/(1-x) and T(k) := (x^(2^k-1) * V(k), U(k) := x^(3*2^(k-1)-1) * V(k) then G.f. is Sum ( i >= 1, T(i) + U(i) ). Functional equation: if the sequence is a(n), n = 1, 2, 3, ... and h(x) := Sum ( n >= 1, x^a(n) ) then h(x) satisfies the following functional equation: (1 + x^2)*h(x^4) - (1 - x)*h(x^2) - x*h(x) + x^2 = 0.
Extensions
New name (using comment from Ralf Stephan) from Joerg Arndt, Aug 31 2014
Comments