[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(1) = 1; for n > 1, a(n) = smallest number > a(n-1) such that pairwise sums and (absolute) differences of distinct elements are all distinct.
6

%I #16 Feb 22 2013 21:38:11

%S 1,2,6,12,21,37,58,84,112,129,173,213,266,307,373,446,513,589,639,829,

%T 916,1061,1209,1297,1429,1461,1626,1783,1964,2220,2576,2653,2875,3064,

%U 3307,3605,3889,4228,4332,4412,4658,5337,5618,5647,6281,6511,7001,7388

%N a(1) = 1; for n > 1, a(n) = smallest number > a(n-1) such that pairwise sums and (absolute) differences of distinct elements are all distinct.

%H Klaus Brockhaus, <a href="/A126428/b126428.txt">Table of n, a(n) for n = 1..2000</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/B2-Sequence.html">B2-Sequence</a>

%H <a href="/index/Br#B_2">Index entries for B_2 sequences</a>

%e a(1) = 1, a(2) = 2; n = 3: k = 3, k-a(2) = 1 = a(2)-a(1), so a(3) > 3; k = 4: k-a(1) = 3 = a(1)+a(2), so a(3) > 4; k = 5: k-a(2) = 3 = a(1)+a(2), so a(3) > 5; k=6: k-a(1) = 5, k-a(2) = 4, k+a(1) = 7, k+a(2) = 8, a(2)-a(1) = 1, a(2)+a(1) = 3 are all distinct, hence a(3) = 6.

%o (PARI) {m=48; u=[]; s=Set(); k=0; for(n=1, m, b=1; while(b, b=0; k++; j=0; while(!b&&j<#u, j++; if(setsearch(s, k-u[j])||setsearch(s, k+u[j]), b=1))); print1(k, ","); if(n<m, v=vector(#u, j, k-u[j]); w=vector(#u, j, k+u[j]); s=setunion(s, Set(concat(v, w))); u=concat(u, k)))} /* Klaus Brockhaus, Sep 05 2007 */

%o (Haskell)

%o import Data.List (intersect)

%o a126428 n = a126428_list !! (n-1)

%o a126428_list = magics 1 [] [] where

%o magics :: Integer -> [Integer] -> [Integer] -> [Integer]

%o magics n ms tests

%o | tests `intersect` nMinus == [] && tests `intersect` nPlus == []

%o = n : magics (n+1) (n:ms) (nMinus ++ nPlus ++ tests)

%o | otherwise

%o = magics (n+1) ms tests

%o where nMinus = map (n -) ms

%o nPlus = map (n +) ms

%o -- magics is the generator for a004210_list, cf. A004210, magic integers.

%o -- _Reinhard Zumkeller_, Mar 03 2011

%Y Cf. A005282 (Mian-Chowla sequence).

%K nonn

%O 1,2

%A Philippe Lallouet (philip.lallouet(AT)wanadoo.fr), Mar 11 2007, Jul 27 2007

%E Edited and extended by _Klaus Brockhaus_, Sep 05 2007