login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A231354
Least k such that n - triangular(k) is a square, or -1 if no such k exists.
1
0, 0, 1, 2, 0, 1, 3, 2, -1, 0, 1, 4, 2, -1, 4, 3, 0, 1, -1, 2, -1, 6, 3, -1, 5, 0, 1, -1, 2, 7, 6, 3, 7, -1, -1, 4, 0, 1, -1, 2, 5, -1, 3, -1, 7, 8, 4, -1, -1, 0, 1, 5, 2, 7, 9, 3, 10, 6, -1, 4, -1, 8, -1, -1, 0, 1, 11, 2, -1, -1, 3, 10, 8, -1, 4, 11, -1, 7, 12, 5, 10, 0
OFFSET
0,4
COMMENTS
Indices of -1's: A014134.
Indices of 0's: A000290.
Indices of 1's: A002522.
PROG
(Python)
import math
for n in range(333):
for k in range(1000000):
t = n - k*(k+1)/2
if t<0:
print('-1', end=', ')
break
r = int(math.sqrt(t))
if r*r==t:
print(str(k), end=', ')
break
CROSSREFS
KEYWORD
sign
AUTHOR
Alex Ratushnyak, Nov 08 2013
STATUS
approved