# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a295290 Showing 1-1 of 1 %I A295290 #12 Oct 16 2020 06:28:39 %S A295290 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 A295290 -1,-1,28,28,45,55,-1,36,-1,-1,36,36,-1,-1,55,-1,45,78,-1,45,45,55,-1, %U A295290 -1,-1,66,55,-1,78,55,55,105,66,-1,-1,-1,-1,66,-1,-1,66 %N A295290 a(n) is the smallest triangular number t such that t - n is a square, or -1 if no such triangular number exists. %C A295290 Smallest triangular number (A000217) that exceeds a square by exactly n, or -1 if there is no such triangular number. %H A295290 Robert Israel, Table of n, a(n) for n = 0..10000 %F A295290 a(t) = t for every triangular number t. %F A295290 a(t-1) = t for every positive triangular number t. %e A295290 a(0) = 0 because 0 is the smallest number that is both triangular and square. %e A295290 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 A295290 a(4) = -1 because there exists no triangular number t such that t - 4 is a square. %p A295290 f:= proc(n) local s,t,R, v, R0; %p A295290 R:= [isolve(s^2 - 2*t^2 = 8*n+1)]; %p A295290 if R = [] then return -1 fi; %p A295290 v:= indets(R,name) minus {s,t}; %p A295290 R0:= remove(hastype,eval(R,v[1]=0),negative); %p A295290 s:= subs(R0[1],s); %p A295290 (s^2-1)/8; %p A295290 end proc: %p A295290 map(f, [$0..100]); # _Robert Israel_, Nov 22 2017 %t A295290 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 A295290 a /@ Range[0, 100] (* _Jean-François Alcover_, Oct 16 2020 *) %Y A295290 Cf. A000217 (triangular numbers), A000290 (squares), A001100 (square triangular numbers). %K A295290 sign %O A295290 0,3 %A A295290 _Jon E. Schoenfield_, Nov 19 2017 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE