OFFSET
1,1
LINKS
Martin Burtscher, Igor Szczyrba, and RafaĆ Szczyrba, Analytic Representations of the n-anacci Constants and Generalizations Thereof, Journal of Integer Sequences, Vol. 18 (2015), Article 15.4.5.
Index entries for linear recurrences with constant coefficients, signature (1,1,1,1).
FORMULA
a(n) = a(n-1) + a(n-2) + a(n-3) + a(n-4) where n >= 5 and a(1) = 2, a(2) = 3, a(3) = 5 and a(4) = 7.
G.f.: x*(1-x)*(2+3*x+3*x^2) / ( 1-x-x^2-x^3-x^4 ). - R. J. Mathar, Feb 03 2011
EXAMPLE
The fifth term is 2 + 3 + 5 + 7 = 17.
MATHEMATICA
LinearRecurrence[{1, 1, 1, 1}, {2, 3, 5, 7}, 40] (* G. C. Greubel, Jun 30 2022 *)
PROG
(PARI) a(n)=([0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1; 1, 1, 1, 1]^(n-1)*[2; 3; 5; 7])[1, 1] \\ Charles R Greathouse IV, Nov 01 2018
(Magma) [n le 4 select NthPrime(n) else Self(n-1)+Self(n-2)+Self(n-3)+Self(n-4): n in [1..41]]; // G. C. Greubel, Jun 30 2022
(SageMath)
@CachedFunction
def a(n): # a = A100532
if (n<5): return nth_prime(n)
else: return sum( a(n-j) for j in (1..4))
[a(n) for n in (1..40)] # G. C. Greubel, Jun 30 2022
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Parthasarathy Nambi, Nov 24 2004
STATUS
approved