login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A295290 a(n) is the smallest triangular number t such that t - n is a square, or -1 if no such triangular number exists. 1

%I #12 Oct 16 2020 06:28:39

%S 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,

%T -1,-1,28,28,45,55,-1,36,-1,-1,36,36,-1,-1,55,-1,45,78,-1,45,45,55,-1,

%U -1,-1,66,55,-1,78,55,55,105,66,-1,-1,-1,-1,66,-1,-1,66

%N a(n) is the smallest triangular number t such that t - n is a square, or -1 if no such triangular number exists.

%C Smallest triangular number (A000217) that exceeds a square by exactly n, or -1 if there is no such triangular number.

%H Robert Israel, <a href="/A295290/b295290.txt">Table of n, a(n) for n = 0..10000</a>

%F a(t) = t for every triangular number t.

%F a(t-1) = t for every positive triangular number t.

%e a(0) = 0 because 0 is the smallest number that is both triangular and square.

%e a(12) = 21 because 21 - 12 = 9 = 3^2 and there is no triangular number t < 21 such that t - 12 is a square.

%e a(4) = -1 because there exists no triangular number t such that t - 4 is a square.

%p f:= proc(n) local s,t,R, v, R0;

%p R:= [isolve(s^2 - 2*t^2 = 8*n+1)];

%p if R = [] then return -1 fi;

%p v:= indets(R,name) minus {s,t};

%p R0:= remove(hastype,eval(R,v[1]=0),negative);

%p s:= subs(R0[1],s);

%p (s^2-1)/8;

%p end proc:

%p map(f, [$0..100]); # _Robert Israel_, Nov 22 2017

%t 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]]]];

%t a /@ Range[0, 100] (* _Jean-François Alcover_, Oct 16 2020 *)

%Y Cf. A000217 (triangular numbers), A000290 (squares), A001100 (square triangular numbers).

%K sign

%O 0,3

%A _Jon E. Schoenfield_, Nov 19 2017

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 29 00:26 EDT 2024. Contains 371264 sequences. (Running on oeis4.)