OFFSET
1,3
COMMENTS
The question originated from the first puzzle 'Low Budget' in the book Mathematical Puzzles and Curiosities.
REFERENCES
I. David, T. Khovanova, and Y. Shpilman, Mathematical Puzzles and Curiosities, World Scientific, 2026, p. 2.
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..10000
Index entries for linear recurrences with constant coefficients, signature (3,-2,-2,3,-1).
FORMULA
a(n) = n*(n^2+3*n-19)/6 + (51-3*(-1)^n)/12, for n > 1.
G.f.: x^2*(1 + x + 2*x^3 - 2*x^4)/((1 - x)^4*(1 + x)). - Stefano Spezia, Feb 20 2026
From Enrique Navarrete, Feb 26 2026: (Start)
a(n) = 3*a(n-1) - 2*a(n-2) - 2*a(n-3) + 3*a(n-4) - a(n-5) for n > 6.
E.g.f.: (1/12)*(2*x^3 + 12*x^2 - 30*x + 51)*exp(x) - (1/4)*exp(-x) - 2*x - 4. (End)
EXAMPLE
For n=4, the minimum cost is achieved by buying 4 vouchers in the following order: 3, 2, 1, 4. The cost is 3+3*2+2*1+1*4=15. The maximum cost is achieved when we buy 4 vouchers in the following order: 2, 4, 3, 1. The cost is 2+2*4+4*3+3*1=25. Thus, a(4) = 25-15 = 10.
MATHEMATICA
A393532[n_] := If[n == 1, 0, (2*n*(n*(n + 3) - 19) - 3*(-1)^n + 51)/12]; Array[A393532, 50] (* or *)
LinearRecurrence[{3, -2, -2, 3, -1}, {0, 1, 4, 10, 22, 39}, 50] (* Paolo Xausa, Feb 25 2026 *)
PROG
(PARI) a(n)= binomial(n+2, 3) - 7*n\2 + 4 - 2*(1==n); \\ Ruud H.G. van Tol, Mar 04 2026
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Tanya Khovanova and PRIMES STEP junior group, Feb 18 2026
STATUS
approved
