OFFSET
0,1
COMMENTS
For n>0, a(n) <= 2*n-1, because n*(n+1)/2 + (2*n-1)*2*n = (9*n^2 - 3*n)/2 = 3*n*(3*n-1)/2 = triangular(3*n-1).
The subsequence with terms less than 2*n-1 begins: 2, 5, 3, 6, 9, 4, 9, 8, 10, 14, 9, 5, 21, 18, 21, 14, 22, 6, 11, 13, 15, ...
The sequence of n's such that a(n) < 2*n-1 begins: 5, 8, 11, 12, 15, 19, 20, 22, 25, 26, ...
MATHEMATICA
lktrno[n_]:=Module[{t=(n(n+1))/2, k=1}, While[!IntegerQ[(Sqrt[ 8(t+k(k+1))+1]-1)/2], k++]; k]; Array[lktrno, 70, 0] (* Harvey P. Dale, Aug 19 2014 *)
PROG
(Python)
def isTriangular(a):
sr = 1L << (long.bit_length(long(a)) >> 1)
a += a
while a < sr*(sr+1): sr>>=1
b = sr>>1
while b:
s = sr+b
if a >= s*(s+1): sr = s
b>>=1
return (a==sr*(sr+1))
n = tn = 0
while 1:
for m in range(1, 1000000000):
if isTriangular(tn + m*(m+1)): break
print str(m)+', ',
n += 1
tn += n
(PARI) a(n)=for(k=1, 2*n, t=n*(n+1)/2+k*(k+1); x=sqrtint(2*t); if(t==x*(x+1)/2, return(k))) /* from Ralf Stephan */
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, May 17 2013
STATUS
approved