OFFSET
1,1
COMMENTS
With triangular sum T(i) = i*(i+1)/2 = Sum_{j=1..i} i, the aim is T(m) - T(k) = b^n for some b. T(m) - T(k) = (m+k+1)*(m-k)/2 so if m-k is odd then use m-k = b^x to eliminate k in the other factor (m+k+1)/2 = b^(n-x), so that m = b^(n-x) + (b^x - 1)/2. If instead m+k+1 is odd then the resulting expression is the same. This form is an integer and minimized at b=3 and x = ceiling(n/2). - Kevin Ryde, May 18 2024
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,3,-3).
FORMULA
a(n) = A087503(n-1) + 1.
a(n) = 3*a(n-2) + 1.
G.f.: x*(2 + 2*x - 3*x^2)/((1 - x)*(1 - 3*x^2)). - Stefano Spezia, May 18 2024
EXAMPLE
a(2) = 4 because the sum of all integers from 3 + 1 to 4 inclusive is 4 = 2^2, a square.
a(3) = 7 as we have 2 + 3 + 4 + 5 + 6 + 7 = 27 = 3^3, i.e., m = 7 and k = 1. - David A. Corneth, May 15 2024
MATHEMATICA
LinearRecurrence[{1, 3, -3}, {2, 4, 7}, 50] (* Paolo Xausa, Jun 09 2024 *)
PROG
(PARI) isok(m, n) = my(s = m*(m+1)/2); for (k=1, m-1, s -= k; if (ispower(s, n), return(k)); );
a(n) = my(m=1); while (! isok(m, n), m++); m; \\ Michel Marcus, May 16 2024
(PARI) a(n) = {
my(res, c, l, u);
res = 2^n; c = 8*3^n;
l = (sqrt(c) - 1)\2; u = res;
for(i = l, u,
if(issquare(4*(i + 1)*i + 1 - c),
return(i);
)
);
return(2^n)
} \\ David A. Corneth, May 16 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jean-Marc Rebert, May 14 2024
EXTENSIONS
More terms from David A. Corneth, May 16 2024
STATUS
approved