The OEIS is supported by the many generous donors to the OEIS Foundation.

Solution of the complementary equation a(n) = 2*a(n-1) - a(n-2) + b(n-1) -2, where a(0) = 1, a(1) = 2, b(0) = 3, and (a(n)) and (b(n)) are increasing complementary sequences.

2

`%I #4 Nov 18 2017 09:06:36
`

`%S 1,2,5,12,24,42,67,100,142,195,260,338,430,537,660,800,958,1135,1332,
`

`%T 1550,1791,2056,2346,2662,3005,3376,3776,4206,4667,5160,5686,6246,
`

`%U 6841,7472,8140,8846,9591,10377,11205,12076,12991,13951,14957,16010,17111,18261
`

`%N Solution of the complementary equation a(n) = 2*a(n-1) - a(n-2) + b(n-1) -2, where a(0) = 1, a(1) = 2, b(0) = 3, and (a(n)) and (b(n)) are increasing complementary sequences.
`

`%C The increasing complementary sequences a() and b() are uniquely determined by the titular equation and initial values. See A294860 for a guide to related sequences.
`

`%H Clark Kimberling, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL10/Kimberling/kimberling26.html">Complementary equations</a>, J. Int. Seq. 19 (2007), 1-13.
`

`%e a(0) = 1, a(1) = 2, b(0) = 3
`

`%e b(1) = 4 (least "new number")
`

`%e a(2) = 2*a(1) - a(0) + b(1) - 2 = 5
`

`%e Complement: (b(n)) = (3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 15, ...)
`

`%t mex := First[Complement[Range[1, Max[#1] + 1], #1]] &;
`

`%t a[0] = 1; a[1] = 2; b[0] = 3;
`

`%t a[n_] := a[n] = 2 a[n - 1] - a[n - 2] + b[n - 1] - 2;
`

`%t b[n_] := b[n] = mex[Flatten[Table[Join[{a[n]}, {a[i], b[i]}], {i, 0, n - 1}]]];
`

`%t Table[a[n], {n, 0, 18}] (* A294868 *)
`

`%t Table[b[n], {n, 0, 10}]
`

`%Y Cf. A294860.
`

`%K nonn,easy
`

`%O 0,2
`

`%A _Clark Kimberling_, Nov 16 2017
`