%I #27 Aug 17 2017 11:57:47
%S 1,6,45,-1,15,36,21,120,-1,210,66,36,78,210,45,-1,1326,378,190,120,
%T 210,66,1035,4560,-1,78,1485,1540,435,300,465,902496,1485,3570,105,-1,
%U 17205,4560,2145,120,861,630,903,157080,4095,276,9870,41328,-1,300,153,780,5565,1185030
%N a(1) = 1; for n > 1, a(n) = smallest triangular number which is n times another triangular number > 1, or -1 if no such number exists.
%C a(b^2) = -1 for b > 1 because (2*b*m + b - 1)^2 < 1 + 4*b^2*m^2 + 4*b^2*m < (2*b*m + b)^2. - _Sascha Kurz_, Jan 27 2003
%H Robert Israel, <a href="/A077672/b077672.txt">Table of n, a(n) for n = 1..10000</a>
%e a(5) = 15 = 5*3, a(6) = 630 = 105*6.
%p f:= proc(n) local eq, X,Y,S,i,Si,XY,y;
%p if issqr(n) then return -1 fi;
%p eq:= n*(X^2-1)=Y^2-1;
%p S:= map(t -> subs(t, [X,Y]), [isolve(eq)]);
%p for i from 0 do
%p Si:= select(t -> t[1] > 3 and t[1]::odd and t[2]>0, expand(subs(_Z1=i, S)));
%p if Si <> [] then
%p XY:= Si[min[index](map(t -> t[1],Si))];
%p y:= (XY[2]-1)/2;
%p return y*(y+1)/2;
%p fi
%p od
%p end proc:
%p f(1):= 1:
%p map(f, [$1..100]); # _Robert Israel_, Aug 15 2017
%t With[{s = Map[# (# + 1)/2 &, Range[10^4]]}, Table[2 Boole[n == 1] + If[IntegerQ[Sqrt@ n], -1, SelectFirst[n Rest@ s, MemberQ[s, #] &]], {n, 54}]] (* _Michael De Vlieger_, Aug 15 2017 *)
%o (PARI) isok(k, n) = {my(t = k*(k+1)/2); !(t % n) && (t/n != 1) && ispolygonal(t/n, 3);}
%o a(n) = {if (n == 1, return (1)); if (issquare(n), return (-1)); my(k = 1); while (!isok(k, n), k++); k*(k+1)/2;} \\ _Michel Marcus_, Aug 15 2017
%Y Cf. A000217 (triangular numbers), A000290 (squares).
%K sign
%O 1,2
%A _Amarnath Murthy_, Nov 16 2002
%E More terms from _Sascha Kurz_, Jan 27 2003
%E More terms from _Michel Marcus_, Aug 15 2017