OFFSET
1,6
COMMENTS
a(n) is also the difference between ((n+1)/2)^2 and Q, where Q is the smallest square which exceeds n by a square q (or by 0 if n itself is a square): ((n+1) / 2)^2 - a(n) = Q; Q - n = q; (Q, q squares of an integer if n is odd).
If n is an odd nonprime > 1, a(n)/16 is the product of two triangular numbers (see A085780).
If n is 1, a prime or a power of 2, a(n) = 0.
FORMULA
a(n) = (f1^2 - 1)*(f2^2 - 1)/4 (with f1 and f2 the nearest integers such that f1*f2 = n).
EXAMPLE
a(15) = 48 because 6*8 = 12*4 = 48 and 6 + 8 = 15 - 1; 12 + 4 = 15 + 1.
a(45) = 480 because 20*24 = 16*30 = 480 and 20 + 24 = 45 - 1; 16 + 30 = 45 + 1.
(Also 448 = 28*16 = 14*32, but 480 is larger.)
MATHEMATICA
a[n_] := Module[{x, y, p}, Max[p /. List@ToRules@Reduce[p == x*(n-1-x) == y*(n+1-y), {x, y, p}, Integers]]]; Table[a[n], {n, 100}] (* Giovanni Resta, Jan 22 2013 *)
PROG
(PARI) a(n) = {my(x=vector(n\2), y=vector(n\2)); for(k=1, n\2, x[k]=k*(n-1-k); y[k]=k*(n+1-k)); v=setintersect(x, y); if(#v>0, v[#v], 0); } \\ Jinyuan Wang, Oct 13 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Enric Reverter i Bigas, Jan 20 2013
STATUS
approved