cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A056231 #13 Dec 17 2019 07:37:27
%S A056231 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 A056231 48,49,50,53,54,55,56,58,60,61,62,64,67,68,69,71,76,77,78,79,82,83,84,
%U A056231 86,87,89,92,96,98,100,101,102,104,105,106,108,113,115
%N 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.
%H A056231 Reinhard Zumkeller, <a href="/A056231/b056231.txt">Table of n, a(n) for n = 1..10000</a>
%e A056231 Array begins
%e A056231 1 2 4 7 8 10 12 ...
%e A056231 .3 6 11 15 18 ...
%e A056231 . 9 17 26 33 ...
%p A056231 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 A056231 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 A056231 else if h[n]<>1 then m := [op(m), n]; fi; fi; od; od; a; b; c; m;
%t A056231 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 A056231 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 A056231 {a, b, c, m} (* _Jean-François Alcover_, Dec 17 2019, translated from Maple *)
%o A056231 (Haskell)
%o A056231 import Data.List (transpose)
%o A056231 a056231 n = ([1,2] ++ threeRows !! 0) !! (n-1)
%o A056231 a056232 n = ([3] ++ threeRows !! 1) !! (n-1)
%o A056231 a056233 n = threeRows !! 2 !! (n-1)
%o A056231 threeRows = transpose $ f [4..] [1,2,3] [2,1] [3] [] where
%o A056231    f (u:free) used us vs ws
%o A056231        | u `notElem` used &&
%o A056231          v `notElem` used &&
%o A056231          w `notElem` used = [u, v, w] :
%o A056231                             f free (w:v:u:used) (u:us) (v:vs) (w:ws)
%o A056231        | otherwise        = f free used us vs ws
%o A056231        where v = u + head us; w = v + head vs
%o A056231 -- _Reinhard Zumkeller_, Oct 18 2011
%Y A056231 Cf. A056232, A056233, A056234. See also A057153, A052474, A057154, A056230.
%K A056231 nonn,nice,easy
%O A056231 1,2
%A A056231 _N. J. A. Sloane_, E. M. Rains, Aug 22 2000