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.

Showing 1-9 of 9 results.

A005228 Sequence and first differences (A030124) together list all positive numbers exactly once.

Original entry on oeis.org

1, 3, 7, 12, 18, 26, 35, 45, 56, 69, 83, 98, 114, 131, 150, 170, 191, 213, 236, 260, 285, 312, 340, 369, 399, 430, 462, 495, 529, 565, 602, 640, 679, 719, 760, 802, 845, 889, 935, 982, 1030, 1079, 1129, 1180, 1232, 1285, 1339, 1394, 1451, 1509, 1568, 1628, 1689
Offset: 1

Views

Author

Keywords

Comments

This is the lexicographically earliest sequence that together with its first differences (A030124) contains every positive integer exactly once.
Hofstadter introduces this sequence in his discussion of Scott Kim's "FIGURE-FIGURE" drawing. - N. J. A. Sloane, May 25 2013
A225850(a(n)) = 2*n-1, cf. A167151. - Reinhard Zumkeller, May 17 2013
In view of the definition of A075326: start with a(0) = 0, and extend by rule that the next term is the sum of the predecessor and the most recent non-member of the sequence. - Reinhard Zumkeller, Oct 26 2014

Examples

			Sequence reads 1 3 7 12 18 26 35 45..., differences are 2 4 5, 6, 8, 9, 10 ... and the point is that every number not in the sequence itself appears among the differences. This property (together with the fact that both the sequence and the sequence of first differences are increasing) defines the sequence!
		

References

  • E. Angelini, "Jeux de suites", in Dossier Pour La Science, pp. 32-35, Volume 59 (Jeux math'), April/June 2008, Paris.
  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 73.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A030124 (complement), A037257, A056731, A056738, A140778, A225687.
Cf. A225850, A232746, A232747 (inverse), A232739, A232740, A232750 and also permutation pair A232751/A232752 constructed from this sequence and its complement.
Cf. A001651 (analog with sums instead of differences), A121229 (analog with products).
The same recurrence a(n) = a(n-1) + c(n-1) with different starting conditions: A061577 (starting with 2), A022935 (3), A022936 (4), A022937 (5), A022938 (6).
Related recurrences:
a(n-1) + c(n+1) - A022953, A022954.
a(n-1) + c(n) - A022946 to A022952.
a(n-1) + c(n-2) - A022940, A022941.
a(n-2) + c(n-1) - A022942 to A022944.
a(n-2) + c(n-2) - A022939.
a(n-3) + c(n-3) - A022955.
a(n-4) + c(n-4) - A022956.
a(n-5) + c(n-5) - A022957.

Programs

  • Haskell
    a005228 = scanl (+) 1 a030124
    a030124 = go 1 a005228 where go x ys | x < head ys = x     : go (x + 1) ys
                                         | otherwise   = x + 1 : go (x + 2) (tail ys)
    -- Maks Verver, Jun 30 2025
    
  • Maple
    maxn := 5000; h := array(1..5000); h[1] := 1; a := [1]; i := 1; b := []; for n from 2 to 1000 do if h[n] <> 1 then b := [op(b), n]; j := a[i]+n; if j < maxn then a := [op(a),j]; h[j] := 1; i := i+1; fi; fi; od: a; b; # a is A005228, b is A030124.
    A030124 := proc(n)
        option remember;
        local a,fnd,t ;
        if n <= 1 then
            op(n+1,[2,4]) ;
        else
            for a from procname(n-1)+1 do
                fnd := false;
                for t from 1 to n+1 do
                    if A005228(t)  = a then
                        fnd := true;
                        break;
                    end if;
                end do:
                if not fnd then
                    return a;
                end if;
            end do:
        end if;
    end proc:
    A005228 := proc(n)
        option remember;
        if n <= 2 then
            op(n,[1,3]) ;
        else
            procname(n-1)+A030124(n-2) ;
        end if;
    end proc: # R. J. Mathar, May 19 2013
  • Mathematica
    a = {1}; d = 2; k = 1; Do[ While[ Position[a, d] != {}, d++ ]; k = k + d; d++; a = Append[a, k], {n, 1, 55} ]; a
    (* Second program: *)
    (* Program from Larry Morris, Jan 19 2017: *)
    d = 3; a = {1, 3, 7, 12, 18}; While[ Length[a = Join[a, a[[-1]] + Accumulate[Range[a[[d]] + 1, a[[++d]] - 1]]]] < 50]; a
    (* Comment: This adds as many terms to the sequence as there are numbers in each set of sequential differences. Consequently, the list of numbers it produces may be longer than the limit provided. With the limit of 50 shown, the sequence produced has length 60. *)
  • PARI
    A005228(n,print_all=0,s=1,used=0)={while(n--,used += 1<M. F. Hasler, Feb 05 2013

Formula

a(n) = a(n-1) + c(n-1) for n >= 2, where a(1)=1, a( ) increasing, c( ) = complement of a( ) (c is the sequence A030124).
Let a(n) = this sequence, b(n) = A030124 prefixed by 0. Then b(n) = mex{ a(i), b(i) : 0 <= i < n}, a(n) = a(n-1) + b(n) + 1. (Fraenkel)
a(1) = 1, a(2) = 3; a( ) increasing; for n >= 3, if a(q) = a(n-1)-a(n-2)+1 for some q < n then a(n) = a(n-1) + (a(n-1)-a(n-2)+2), otherwise a(n) = a(n-1) + (a(n-1)-a(n-2)+1). - Albert Neumueller (albert.neu(AT)gmail.com), Jul 29 2006
a(n) = n^2/2 + n^(3/2)/(3*sqrt(2)) + O(n^(5/4)) [proved in Jubin link]. - Benoit Jubin, May 13 2015
For all n >= 1, A232746(a(n)) = n and A232747(a(n)) = n. [Both sequences work as left inverses of this sequence.] - Antti Karttunen, May 14 2015

Extensions

Additional comments from Robert G. Wilson v, Oct 24 2001
Incorrect formula removed by Benoit Jubin, May 13 2015

A294414 Solution of the complementary equation a(n) = a(n-1) + a(n-2) + b(n-1) + b(n-2), where a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4.

Original entry on oeis.org

1, 3, 10, 22, 43, 78, 136, 231, 387, 641, 1053, 1721, 2803, 4555, 7391, 11981, 19409, 31429, 50879, 82352, 133278, 215679, 349008, 564740, 913803, 1478600, 2392462, 3871123, 6263648, 10134836, 16398551, 26533456, 42932078, 69465607, 112397760, 181863444
Offset: 0

Views

Author

Clark Kimberling, Oct 31 2017

Keywords

Comments

The complementary sequences a() and b() are uniquely determined by the titular equation and initial values. The initial values of each sequence in the following guide are a(0) = 1, a(2) = 3, b(0) = 2, b(1) = 4:
A294413: a(n) = a(n-1) + a(n-2) - b(n-1) + 6
A294414: a(n) = a(n-1) + a(n-2) + b(n-1) + b(n-2)
A294415: a(n) = a(n-1) + a(n-2) + b(n-1) + b(n-2) + 1
A294416: a(n) = a(n-1) + a(n-2) + b(n-1) + b(n-2) + n
A294417: a(n) = a(n-1) + a(n-2) + b(n-1) + b(n-2) - n
A294418: a(n) = a(n-1) + a(n-2) + b(n-1) + 2*b(n-2)
A294419: a(n) = a(n-1) + a(n-2) + 2*b(n-1) + 2*b(n-2)
A294420: a(n) = a(n-1) + a(n-2) + 2*b(n-1) + b(n-2)
A294421: a(n) = a(n-1) + a(n-2) + 2*b(n-1) - b(n-2)
A294422: a(n) = a(n-1) + a(n-2) + b(n-1) - b(n-2) + 1
A294423: a(n) = a(n-1) + a(n-2) + b(n-1) - b(n-2) + n
A294424: a(n) = a(n-1) + a(n-2) + b(n-1) + b(n-2) - 1
A294425: a(n) = a(n-1) + a(n-2) + b(n-1) + b(n-2) - 2
A294426: a(n) = a(n-1) + 2*a(n-2) + b(n-1) + b(n-2) - 3
Conjecture: a(n)/a(n-1) -> (1 + sqrt(5))/2, the golden ratio.

Examples

			a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4, so that
a(2)  = a(1) + a(0) + b(1) + b(0) = 6
Complement: (b(n)) = (2, 4, 5, 6, 7, 8, 9, 11, 12, 13, ...)
		

Crossrefs

Programs

  • Mathematica
    mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
    a[0] = 1; a[1] = 3; b[0] = 2; b[1] = 4;
    a[n_] := a[n] = a[n - 1] + a[n - 2] + b[n - 1] + b[n - 2];
    b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
    Table[a[n], {n, 0, 40}]  (* A294414 *)
    Table[b[n], {n, 0, 10}]

Extensions

Definition corrected by Georg Fischer, Sep 27 2020

A022941 a(n) = a(n-1) + c(n-2) for n >= 3, a( ) increasing, given a(1)=1, a(2)=2; where c( ) is complement of a( ).

Original entry on oeis.org

1, 2, 5, 9, 15, 22, 30, 40, 51, 63, 76, 90, 106, 123, 141, 160, 180, 201, 224, 248, 273, 299, 326, 354, 383, 414, 446, 479, 513, 548, 584, 621, 659, 698, 739, 781, 824, 868, 913, 959, 1006, 1054, 1103, 1153, 1205, 1258, 1312, 1367, 1423, 1480, 1538
Offset: 1

Views

Author

Keywords

Comments

Except for a(2), identical to A022940. - Ivan Neretin, Apr 05 2016

Crossrefs

Cf. A143344 (first differences), A156031.
Cf. A005228 and references therein.

Programs

  • Haskell
    import Data.List (delete)
    a022941 n = a022941_list !! (n-1)
    a022941_list = 1 : 2 : f 2 [3..] where
       f x (z:zs) = y : f y (delete y zs) where y = x + z
    -- Reinhard Zumkeller, May 17 2013
  • Maple
    a[1]:=1: a[2]:=2: c[1]:=3: for n from 2 to 70 do c[n]:=c[n-1]+1: for k from 1 to n do if(c[n]<=a[k])then if(c[n]=a[k])then c[n]:=c[n]+1: fi: break: fi: od: a[n+1]:=a[n]+c[n-1]: od: seq(a[n],n=1..70); # Nathaniel Johnston, May 01 2011
  • Mathematica
    Fold[Append[#1, #1[[-1]] + Complement[Range[Max@#1 + 1], #1][[#2]]] &, {1, 2}, Range[50]] (* Ivan Neretin, Apr 04 2016 *)

Extensions

a(27) inserted by Nathaniel Johnston, May 01 2011

A294397 Solution of the complementary equation a(n) = a(n-1) + b(n-2) + 1, where a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4.

Original entry on oeis.org

1, 3, 6, 11, 17, 25, 34, 44, 55, 68, 82, 97, 113, 130, 149, 169, 190, 212, 235, 259, 284, 311, 339, 368, 398, 429, 461, 494, 528, 564, 601, 639, 678, 718, 759, 801, 844, 888, 934, 981, 1029, 1078, 1128, 1179, 1231, 1284, 1338, 1393, 1450, 1508, 1567, 1627
Offset: 0

Views

Author

Clark Kimberling, Oct 30 2017

Keywords

Comments

The complementary sequences a() and b() are uniquely determined by the titular equation and initial values. See A022940 for a guide to related sequences.
Apart from the first two entries this is the same as A081689. - R. J. Mathar, Oct 31 2017

Examples

			a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4, so that
a(2)  = a(1) + b(0) + 1 = 6
Complement: (b(n)) = (2, 4, 5, 7, 8, 10, 11, 12, 13, 14, 16, ...)
		

Crossrefs

Programs

  • Mathematica
    mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
    a[0] = 1; a[1] = 3; b[0] = 2; b[1] = 4;
    a[n_] := a[n] = a[n - 1] + b[n - 2] + 1;
    b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
    Table[a[n], {n, 0, 40}]  (* A294397 *)
    Table[b[n], {n, 0, 10}]

A294398 Solution of the complementary equation a(n) = a(n-1) + b(n-2) + 2, where a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4.

Original entry on oeis.org

1, 3, 7, 13, 20, 28, 38, 49, 61, 74, 88, 104, 121, 139, 158, 178, 199, 222, 246, 271, 297, 324, 352, 381, 412, 444, 477, 511, 546, 582, 619, 657, 696, 737, 779, 822, 866, 911, 957, 1004, 1052, 1101, 1151, 1203, 1256, 1310, 1365, 1421, 1478, 1536, 1595, 1655
Offset: 0

Views

Author

Clark Kimberling, Oct 30 2017

Keywords

Comments

The complementary sequences a() and b() are uniquely determined by the titular equation and initial values. See A022940 for a guide to related sequences.

Examples

			a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4, so that
a(2)  = a(1) + b(0) + 2 = 7
Complement: (b(n)) = (2, 4, 5, 6, 8, 10, 11, 12, 13, 14, 16, ...)
		

Crossrefs

Programs

  • Mathematica
    mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
    a[0] = 1; a[1] = 3; b[0] = 2; b[1] = 4;
    a[n_] := a[n] = a[n - 1] + b[n - 2] + 2;
    b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
    Table[a[n], {n, 0, 40}]  (* A294398 *)
    Table[b[n], {n, 0, 10}]

A294399 Solution of the complementary equation a(n) = a(n-1) + b(n-2) + 3, where a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4.

Original entry on oeis.org

1, 3, 8, 15, 23, 32, 42, 54, 67, 81, 96, 112, 129, 148, 168, 189, 211, 234, 258, 283, 310, 338, 367, 397, 428, 460, 493, 527, 563, 600, 638, 677, 717, 758, 800, 843, 887, 933, 980, 1028, 1077, 1127, 1178, 1230, 1283, 1337, 1392, 1448, 1506, 1565, 1625, 1686
Offset: 0

Views

Author

Clark Kimberling, Oct 30 2017

Keywords

Comments

The complementary sequences a() and b() are uniquely determined by the titular equation and initial values. See A022940 for a guide to related sequences.

Examples

			a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4, so that
a(2)  = a(1) + b(0) + 3 = 8
Complement: (b(n)) = (2, 4, 5, 6, 7, 10, 11, 12, 13, 14, 16, ...)
		

Crossrefs

Programs

  • Mathematica
    mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
    a[0] = 1; a[1] = 3; b[0] = 2; b[1] = 4;
    a[n_] := a[n] = a[n - 1] + b[n - 2] + 3;
    b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
    Table[a[n], {n, 0, 40}]  (* A294399 *)
    Table[b[n], {n, 0, 10}]

A294400 Solution of the complementary equation a(n) = a(n-1) + b(n-2) + n, where a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4.

Original entry on oeis.org

1, 3, 7, 14, 23, 34, 48, 64, 82, 102, 124, 148, 175, 204, 235, 268, 303, 340, 379, 420, 464, 510, 558, 608, 660, 714, 770, 828, 888, 950, 1015, 1082, 1151, 1222, 1295, 1370, 1447, 1526, 1607, 1690, 1775, 1862, 1951, 2043, 2137, 2233, 2331, 2431, 2533, 2637
Offset: 0

Views

Author

Clark Kimberling, Oct 31 2017

Keywords

Comments

The complementary sequences a() and b() are uniquely determined by the titular equation and initial values. See A022940 for a guide to related sequences.

Examples

			a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4, so that
a(2)  = a(1) + b(0) + 2 = 7
Complement: (b(n)) = (2, 4, 5, 6, 8, 10, 11, 12, 13, 15, 16, ...)
		

Crossrefs

Programs

  • Mathematica
    mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
    a[0] = 1; a[1] = 3; b[0] = 2; b[1] = 4;
    a[n_] := a[n] = a[n - 1] + b[n - 2] + n;
    b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
    Table[a[n], {n, 0, 40}]  (* A294400 *)
    Table[b[n], {n, 0, 10}]

A294401 Solution of the complementary equation a(n) = a(n-1) + b(n-2) + 2n, where a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4.

Original entry on oeis.org

1, 3, 9, 19, 32, 48, 67, 89, 115, 144, 176, 211, 249, 290, 334, 381, 431, 485, 542, 602, 665, 731, 800, 872, 947, 1025, 1106, 1190, 1277, 1368, 1462, 1559, 1659, 1762, 1868, 1977, 2089, 2204, 2322, 2443, 2567, 2694, 2824, 2957, 3094, 3234, 3377, 3523, 3672
Offset: 0

Views

Author

Clark Kimberling, Oct 31 2017

Keywords

Comments

The complementary sequences a() and b() are uniquely determined by the titular equation and initial values. See A022940 for a guide to related sequences.

Examples

			a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4, so that
a(2)  = a(1) + a(0) + 4 = 9.
Complement: (b(n)) = (2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, ...)
		

Crossrefs

Programs

  • Mathematica
    mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
    a[0] = 1; a[1] = 3; b[0] = 2; b[1] = 4;
    a[n_] := a[n] = a[n - 1] + b[n - 2] + 2 n;
    b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
    Table[a[n], {n, 0, 40}]  (* A294401 *)
    Table[b[n], {n, 0, 10}]

A294412 Solution of the complementary equation a(n) = a(n-1) + 2*b(n-2) + 1, where a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4.

Original entry on oeis.org

1, 3, 8, 17, 28, 41, 56, 75, 96, 119, 144, 171, 200, 231, 264, 301, 340, 381, 424, 469, 516, 565, 616, 669, 724, 783, 844, 907, 972, 1039, 1108, 1179, 1252, 1327, 1404, 1483, 1564, 1649, 1736, 1825, 1916, 2009, 2104, 2201, 2300, 2401, 2504, 2609, 2716, 2825
Offset: 0

Views

Author

Clark Kimberling, Oct 31 2017

Keywords

Comments

The complementary sequences a() and b() are uniquely determined by the titular equation and initial values. See A022940 for a guide to related sequences.

Examples

			a(0) = 1, a(1) = 3, b(0) = 2, b(1) = 4, so that
a(2)  = a(1) + 2*b(0) + 1 = 8
Complement: (b(n)) = (2, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, ...)
		

Crossrefs

Programs

  • Mathematica
    mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
    a[0] = 1; a[1] = 3; b[0] = 2; b[1] = 4;
    a[n_] := a[n] = a[n - 1] + 2b[n - 2] + 1;
    b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
    Table[a[n], {n, 0, 40}]  (* A294412 *)
    Table[b[n], {n, 0, 10}]
Showing 1-9 of 9 results.