login
A076114
a(n) = start of the smallest string of n consecutive positive integers with a square sum, or 0 if no such number exists.
6
1, 4, 2, 0, 3, 11, 4, 1, 5, 18, 6, 0, 7, 25, 8, 0, 9, 4, 10, 0, 11, 39, 12, 2, 4, 46, 14, 0, 15, 53, 16, 9, 17, 60, 18, 0, 19, 67, 20, 3, 21, 74, 22, 0, 23, 81, 24, 0, 1, 16, 26, 0, 27, 11, 28, 4, 29, 102, 30, 0, 31, 109, 32, 0, 33, 116, 34, 0, 35, 123, 36, 5, 37, 130, 11, 0, 39
OFFSET
1,2
COMMENTS
Equivalently, smallest k such that n(n+2k-1)/2 is a square, 0 if there is no such square. - Ralf Stephan, Mar 23 2003
a(n) = 0 if and only if n has the form 4^e*m with e > 0 and m odd. - Dean Hickerson, Mar 25 2003
a(k) = 1 if k is the index of a square triangular number, i.e., k(k+1)/2 is a square, or if k belongs to A001108. If n is odd then a(n) <= (n+1)/2.
LINKS
EXAMPLE
a(2) = 4, 4+5 = 9 = 3^2.
a(8) = 1, 1+2+3+4+5+6+7+8 = 36 = 6^2.
PROG
(PARI) a(n) = if (!(n%4) && ((n/4^valuation(n, 4)) % 2), 0, my(o=n*(n+1)/2, k=0); while(!issquare(o+n*k), k++); k+1); \\ corrected by Michel Marcus, Sep 08 2025
(Python)
from itertools import count
from sympy.ntheory.primetest import is_square
def A076114(n):
if not (n&1 or (~n & n-1).bit_length()&1): return 0
return next(a for a in count(1) if is_square(n*(n+(a<<1)-1)>>1)) # Chai Wah Wu, Sep 16 2025
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Oct 09 2002
EXTENSIONS
More terms from Ralf Stephan, Mar 23 2003
STATUS
approved