OFFSET
0,2
COMMENTS
This sequence is mentioned in the Mathologer video in the links section.
LINKS
Burkard Polster, Secrets of the lost number walls, Mathologer video (2022).
Index entries for linear recurrences with constant coefficients, signature (1,-1,3).
FORMULA
a(n) = a(n-1) - a(n-2) + 3*a(n-3) with a(0) = 1, a(1) = 2 and a(2) = 4.
From G. C. Greubel, Aug 31 2022: (Start)
a(n) = A*(r1)^n + B*(r2)^n + C*(r3)^n, where r1 = (1 + x - y)/3, r2 = (2 - (1 + i*sqrt(3))*x +(1-i*sqrt(3))*y)/6, r3 = (2 -(1-i*sqrt(3))*x +(1-i*sqrt(3))*y)/6, x = (9*sqrt(17) + 37)^(1/3), y = (9*sqrt(17) - 37)^(1/3), A = (2-r2)*(2-r3)/((r1-r2)*(r1-r3)), B = (2-r1)*(2-r3)/((r2-r1)*(r2-r3)), C = (2-r1)*(2-r2)/((r3-r1)*(r3-r2)).
G.f.: (1 + x + 3*x^2)/(1 - x + x^2 - 3*x^3). (End)
EXAMPLE
a(4) = 7 because a(3) - a(2) + 3*a(1) = 5 - 4 + 2*3 = 7.
Number wall:
.. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
.. 1 2 4 5 7 14 22 29 49 86 142 185 319 506 ...
.. -1 0 6 -3 -21 42 78 -237 -93 1320 -534 -11073 8151 .......
.. 1 3 9 27 81 243 729 2187 6561 19693 ........................
.. 0 0 0 0 0 0 0 0 0 ..............................
MATHEMATICA
a[1]=1; a[2]=2; a[3]=4; a[n_]:=a[n]=a[n-1]-a[n-2]+3a[n-3]; Array[a, 50]
(* second program *)
LinearRecurrence[{1, -1, 3}, {1, 2, 4}, 40]
PROG
(Magma) [n le 3 select 2^(n-1) else Self(n-1) -Self(n-2) +3*Self(n-3): n in [1..41]]; // G. C. Greubel, Aug 31 2022
(SageMath)
@CachedFunction
def a(n): return 2^n if (n<3) else a(n-1) - a(n-2) + 3*a(n-3) # a = A356849
[a(n) for n in (0..40)] # G. C. Greubel, Aug 31 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Giorgos Kalogeropoulos, Aug 31 2022
STATUS
approved