OFFSET
1,1
COMMENTS
Given the set {1, 2, 3,..., k}, we want to separate it into the disjoint sets {1, 2, 3,..., m} and {m + 1, m + 2,..., k}, so that the sum of the elements of each set is a square.
We want the sum from 1 to m to be a square, that is, m*(m + 1)/2 to be a square. Therefore, m is in A001108. Furthermore, (m + 1) + (m + 2) + ... + k = u^2, where u is an integer. Then, k*(k + 1)/2 - m*(m + 1)/2 = u^2, which can be rewritten as (2*k + 1)^2 - 8*u^2 = (2*m + 1)^2, which is a generalized Pell equation.
LINKS
David Consiglio, Jr., Table of n, a(n) for n = 1..100
David Consiglio, Jr., Python
EXAMPLE
k = 16 is in this sequence since for m = 8, 1 + 2 + 3 +...+ 8 = 6^2 and also 9 + 10 + 11 +...+ 16 = 10^2.
MAPLE
N:= 10^5: # for terms <= N
mf:= proc(i) option remember; 6*procname(i-1) - procname(i-2) + 2 end proc: mf(0):= 0: mf(1):= 1:
R:= {}:
for i from 1 do
m:= mf(i);
if m >= N then break fi;
eq:= K^2 = 8*z^2 + (2*m+1)^2;
S:= [isolve(eq)];
for s in S do
if subs(expand(eval(s, _Z1=1)), [K, z])::list(posint) then
for zi from 0 do
v:= (expand(subs(_Z1=zi, subs(s, K)))-1)/2;
if v > N then break fi;
if v > m then R:= R union {v} fi;
od fi od od:
sort(convert(R, list)); # Robert Israel, Jan 08 2026
CROSSREFS
KEYWORD
nonn
AUTHOR
Gonzalo MartÃnez, Dec 16 2025
STATUS
approved
