cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A372631 Numbers m for which there exists some k < m where the sum of the natural numbers from k^2 to m^2 inclusive is a square.

This page as a plain text file.
%I A372631 #41 May 14 2024 10:41:00
%S A372631 4,5,7,12,15,19,29,34,41,47,55,56,65,71,73,80,84,98,111,119,124,126,
%T A372631 141,158,165,169,175,191,209,231,239,253,260,265,287,322,335,345,352,
%U A372631 359,369,376,403,408,425,436,444,463,465,491,505,532,542,548,587,620
%N A372631 Numbers m for which there exists some k < m where the sum of the natural numbers from k^2 to m^2 inclusive is a square.
%H A372631 Chai Wah Wu, <a href="/A372631/b372631.txt">Table of n, a(n) for n = 1..1301</a>
%H A372631 Nicolay Avilov, <a href="https://www.diofant.ru/problem/3639/">Problem 1876. Segment of a natural series</a> (in Russian).
%e A372631 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.
%t A372631 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 *)
%o A372631 (Python)
%o A372631 from math import isqrt
%o A372631 def ok(m):
%o A372631     tot = m**2*(m**2+1)//2
%o A372631     for k in range(1, m):
%o A372631         skm = tot - k**2*(k**2-1)//2
%o A372631         if isqrt(skm)**2 == skm:
%o A372631             return True
%o A372631     return False
%o A372631 print([m for m in range(621) if ok(m)]) # _Michael S. Branicky_, May 10 2024
%o A372631 (Python)
%o A372631 from itertools import count, islice
%o A372631 from sympy.abc import x,y
%o A372631 from sympy.ntheory.primetest import is_square
%o A372631 from sympy.solvers.diophantine.diophantine import diop_quadratic
%o A372631 def A372631_gen(startvalue=2): # generator of terms >= startvalue
%o A372631     for m in count(max(startvalue,2)):
%o A372631         m2 = m**2
%o A372631         for k in diop_quadratic(m2*(m2+1)-x*(x-1)-2*y**2):
%o A372631             if (r:=int(k[0]))<m2 and is_square(r):
%o A372631                 yield m
%o A372631                 break
%o A372631 A372631_list = list(islice(A372631_gen(),56)) # _Chai Wah Wu_, May 13 2024
%Y A372631 Cf. A000290, A372630.
%K A372631 nonn
%O A372631 1,1
%A A372631 _Nicolay Avilov_, May 07 2024