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”).
%I #13 Dec 17 2019 07:37:27
%S 1,2,4,7,8,10,12,13,14,16,19,20,21,23,28,31,32,34,36,37,38,43,45,46,
%T 48,49,50,53,54,55,56,58,60,61,62,64,67,68,69,71,76,77,78,79,82,83,84,
%U 86,87,89,92,96,98,100,101,102,104,105,106,108,113,115
%N Form an array with 3 rows: row 1 begins with 1; all rows are increasing; each entry is sum of 2 entries above it; each number appears at most once; smallest unused number is appended to first row if possible. Sequence gives row 1.
%H Reinhard Zumkeller, <a href="/A056231/b056231.txt">Table of n, a(n) for n = 1..10000</a>
%e Array begins
%e 1 2 4 7 8 10 12 ...
%e .3 6 11 15 18 ...
%e . 9 17 26 33 ...
%p a := [1,2,4]; an := 3; b := [3,6]; bn := 2; c := [9]; cn := 1; h := array(1..10000); h[1] := 1; h[2] := 1; h[3] := 1; h[4] := 1; h[6] := 1; h[9] := 1; m := []; k := 5;
%p for i from 1 to 200 do for n from k to k+100 do n1 := a[an]+n; n2 := b[bn]+n1; if h[n]<>1 and h[n1]<>1 and h[n2]<>1 then h[n] := 1; h[n1] := 1; h[n2] := 1; an := an+1; bn := bn+1; cn := cn+1; a := [op(a), n]; b := [op(b), n1]; c := [op(c), n2]; k := n+1; break;
%p else if h[n]<>1 then m := [op(m), n]; fi; fi; od; od; a; b; c; m;
%t a = {1, 2, 4}; an = 3; b = {3, 6}; bn = 2; c = {9}; cn = 1; Clear[h]; h[_] = 0; h[1] = h[2] = h[3] = h[4] = h[6] = h[9] = 1; m = {}; k = 5;
%t For[i = 1, i <= 200, i++, For[n = k, n <= k + 100, n++, n1 = a[[an]] + n; n2 = b[[bn]] + n1; If[h[n] != 1 && h[n1] != 1 && h[n2] != 1, h[n] = 1; h[n1] = 1; h[n2] = 1; an++; bn++; cn++; AppendTo[a, n]; AppendTo[b, n1]; AppendTo[c, n2]; k = n+1; Break[], If[h[n] != 1, AppendTo[m, n]]]]];
%t {a, b, c, m} (* _Jean-François Alcover_, Dec 17 2019, translated from Maple *)
%o (Haskell)
%o import Data.List (transpose)
%o a056231 n = ([1,2] ++ threeRows !! 0) !! (n-1)
%o a056232 n = ([3] ++ threeRows !! 1) !! (n-1)
%o a056233 n = threeRows !! 2 !! (n-1)
%o threeRows = transpose $ f [4..] [1,2,3] [2,1] [3] [] where
%o f (u:free) used us vs ws
%o | u `notElem` used &&
%o v `notElem` used &&
%o w `notElem` used = [u, v, w] :
%o f free (w:v:u:used) (u:us) (v:vs) (w:ws)
%o | otherwise = f free used us vs ws
%o where v = u + head us; w = v + head vs
%o -- _Reinhard Zumkeller_, Oct 18 2011
%Y Cf. A056232, A056233, A056234. See also A057153, A052474, A057154, A056230.
%K nonn,nice,easy
%O 1,2
%A _N. J. A. Sloane_, E. M. Rains, Aug 22 2000