OFFSET
1,1
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..1301
Nicolay Avilov, Problem 1876. Segment of a natural series (in Russian).
EXAMPLE
4 is a term because the sum of all natural numbers from 3^2 to 4^2 inclusive is 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 = 100 = 10^2.
MATHEMATICA
a={}; For[m=1, m<=620, m++, flag=0; tot=m^2*(m^2+1)/2; For[k=1, k<m && flag == 0, k++, If[IntegerQ[Sqrt[tot-k^2(k^2-1)/2]], AppendTo[a, m]; flag=1]]]; a (* Stefano Spezia, May 11 2024 after Michael S. Branicky, May 10 2024 *)
PROG
(Python)
from math import isqrt
def ok(m):
tot = m**2*(m**2+1)//2
for k in range(1, m):
skm = tot - k**2*(k**2-1)//2
if isqrt(skm)**2 == skm:
return True
return False
print([m for m in range(621) if ok(m)]) # Michael S. Branicky, May 10 2024
(Python)
from itertools import count, islice
from sympy.abc import x, y
from sympy.ntheory.primetest import is_square
from sympy.solvers.diophantine.diophantine import diop_quadratic
def A372631_gen(startvalue=2): # generator of terms >= startvalue
for m in count(max(startvalue, 2)):
m2 = m**2
for k in diop_quadratic(m2*(m2+1)-x*(x-1)-2*y**2):
if (r:=int(k[0]))<m2 and is_square(r):
yield m
break
CROSSREFS
KEYWORD
nonn
AUTHOR
Nicolay Avilov, May 07 2024
STATUS
approved