A295290 a(n) is the smallest triangular number t such that t - n is a square, or -1 if no such triangular number exists.
0, 1, 3, 3, -1, 6, 6, -1, -1, 10, 10, 15, 21, -1, 15, 15, -1, 21, -1, 28, 21, 21, -1, -1, 28, -1, -1, 28, 28, 45, 55, -1, 36, -1, -1, 36, 36, -1, -1, 55, -1, 45, 78, -1, 45, 45, 55, -1, -1, -1, 66, 55, -1, 78, 55, 55, 105, 66, -1, -1, -1, -1, 66, -1, -1, 66
Offset: 0
Keywords
Examples
a(0) = 0 because 0 is the smallest number that is both triangular and square. a(12) = 21 because 21 - 12 = 9 = 3^2 and there is no triangular number t < 21 such that t - 12 is a square. a(4) = -1 because there exists no triangular number t such that t - 4 is a square.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
Programs
-
Maple
f:= proc(n) local s,t,R, v, R0; R:= [isolve(s^2 - 2*t^2 = 8*n+1)]; if R = [] then return -1 fi; v:= indets(R,name) minus {s,t}; R0:= remove(hastype,eval(R,v[1]=0),negative); s:= subs(R0[1],s); (s^2-1)/8; end proc: map(f, [$0..100]); # Robert Israel, Nov 22 2017
-
Mathematica
a[n_] := Module[{s, t, k}, If[Solve[s^2 - 2t^2 == 8n+1, {s, t}, Integers] == {}, Return[-1]]; For[k = 0, True, k++, t = k(k+1)/2; If[IntegerQ[ Sqrt[t-n]], Return[t]]]]; a /@ Range[0, 100] (* Jean-François Alcover, Oct 16 2020 *)
Formula
a(t) = t for every triangular number t.
a(t-1) = t for every positive triangular number t.
Comments