OFFSET
0,2
COMMENTS
For n>1, a(n) <= b(n), where b(n) = 24*n^2 - 60*n + 36 = A143698(n-1), because b(n) + n^2 = (5*n-6)^2, and b(n) + n*(n+1)/2 = (7*n-9)*(7*n-8)/2 = triangular(7*n-9).
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..10000
EXAMPLE
12 + 2^2 = 16 is a square, and 12 + 2*3/2 = 15 is a triangular number, and 12 is the least such integer, so a(2)=12.
MATHEMATICA
lmst[n_]:=Module[{m=1, n2=n^2, nt=(n(n+1))/2}, While[ !IntegerQ[Sqrt[ m+n2]] || !OddQ[Sqrt[1+8(m+nt)]], m++]; m]; Join[{1}, Array[lmst, 50]] (* Harvey P. Dale, Aug 15 2021 *)
PROG
(PARI) a(n) = {m = 1; while (! (issquare(m+n^2) && ispolygonal(m+n*(n+1)/2, 3)), m++); m; } \\ Michel Marcus, Jan 11 2016
(Python)
from math import sqrt
def A267140(n):
u, r, k, m = 2*n+1, 4*n*(n+1)+1, 0, 2*n+1
while True:
if int(sqrt(8*m+r))**2 == 8*m+r:
return m
k += 2
m += u + k # Chai Wah Wu, Jan 13 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Jan 10 2016
STATUS
approved