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”).

A056231
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.
8
1, 2, 4, 7, 8, 10, 12, 13, 14, 16, 19, 20, 21, 23, 28, 31, 32, 34, 36, 37, 38, 43, 45, 46, 48, 49, 50, 53, 54, 55, 56, 58, 60, 61, 62, 64, 67, 68, 69, 71, 76, 77, 78, 79, 82, 83, 84, 86, 87, 89, 92, 96, 98, 100, 101, 102, 104, 105, 106, 108, 113, 115
OFFSET
1,2
LINKS
EXAMPLE
Array begins
1 2 4 7 8 10 12 ...
.3 6 11 15 18 ...
. 9 17 26 33 ...
MAPLE
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;
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;
else if h[n]<>1 then m := [op(m), n]; fi; fi; od; od; a; b; c; m;
MATHEMATICA
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;
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]]]]];
{a, b, c, m} (* Jean-François Alcover, Dec 17 2019, translated from Maple *)
PROG
(Haskell)
import Data.List (transpose)
a056231 n = ([1, 2] ++ threeRows !! 0) !! (n-1)
a056232 n = ([3] ++ threeRows !! 1) !! (n-1)
a056233 n = threeRows !! 2 !! (n-1)
threeRows = transpose $ f [4..] [1, 2, 3] [2, 1] [3] [] where
f (u:free) used us vs ws
| u `notElem` used &&
v `notElem` used &&
w `notElem` used = [u, v, w] :
f free (w:v:u:used) (u:us) (v:vs) (w:ws)
| otherwise = f free used us vs ws
where v = u + head us; w = v + head vs
-- Reinhard Zumkeller, Oct 18 2011
CROSSREFS
KEYWORD
nonn,nice,easy
AUTHOR
N. J. A. Sloane, E. M. Rains, Aug 22 2000
STATUS
approved