OFFSET
1,2
COMMENTS
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
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(5) = 15 = 5*3, a(6) = 630 = 105*6.
MAPLE
f:= proc(n) local eq, X, Y, S, i, Si, XY, y;
if issqr(n) then return -1 fi;
eq:= n*(X^2-1)=Y^2-1;
S:= map(t -> subs(t, [X, Y]), [isolve(eq)]);
for i from 0 do
Si:= select(t -> t[1] > 3 and t[1]::odd and t[2]>0, expand(subs(_Z1=i, S)));
if Si <> [] then
XY:= Si[min[index](map(t -> t[1], Si))];
y:= (XY[2]-1)/2;
return y*(y+1)/2;
fi
od
end proc:
f(1):= 1:
map(f, [$1..100]); # Robert Israel, Aug 15 2017
MATHEMATICA
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 *)
PROG
(PARI) isok(k, n) = {my(t = k*(k+1)/2); !(t % n) && (t/n != 1) && ispolygonal(t/n, 3); }
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
CROSSREFS
KEYWORD
sign
AUTHOR
Amarnath Murthy, Nov 16 2002
EXTENSIONS
More terms from Sascha Kurz, Jan 27 2003
More terms from Michel Marcus, Aug 15 2017
STATUS
approved