OFFSET
1,2
LINKS
Klaus Brockhaus, Table of n, a(n) for n = 1..2000
Eric Weisstein's World of Mathematics, B2-Sequence
EXAMPLE
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.
PROG
(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 */
(Haskell)
import Data.List (intersect)
a126428 n = a126428_list !! (n-1)
a126428_list = magics 1 [] [] where
magics :: Integer -> [Integer] -> [Integer] -> [Integer]
magics n ms tests
| tests `intersect` nMinus == [] && tests `intersect` nPlus == []
= n : magics (n+1) (n:ms) (nMinus ++ nPlus ++ tests)
| otherwise
= magics (n+1) ms tests
where nMinus = map (n -) ms
nPlus = map (n +) ms
-- magics is the generator for a004210_list, cf. A004210, magic integers.
-- Reinhard Zumkeller, Mar 03 2011
CROSSREFS
KEYWORD
nonn
AUTHOR
Philippe Lallouet (philip.lallouet(AT)wanadoo.fr), Mar 11 2007, Jul 27 2007
EXTENSIONS
Edited and extended by Klaus Brockhaus, Sep 05 2007
STATUS
approved