%I #16 May 03 2019 19:32:18
%S 0,5,14,26,41,60,82,105,134,164,197,234,272,314,359,407,456,507,566,
%T 623,686,748,812,883,956,1030,1107,1181,1267,1354,1445,1529,1620,1721,
%U 1814,1920,2022,2121,2232,2344,2460,2573,2691,2815,2936,3061,3189,3321,3462
%N Number of distinct nonzero values taken by (x1-x2)^2 + (y1-y2)^2 for x1, y1, x2, y2 integers with 0 <= (x1,y1) <= n and -n <= (x2,y2) <= 0.
%C In the x-y plane, lengths of line segments between lattice points P1=(x1,y1) with 0 <= (x1,y1) <= n and lattice points P2=(x2,y2) with -n <= (x2,y2) <= 0.
%e For n=1, distances P1 to P2 can take 5 distinct nonzero values, whose squared distances are {1,2,4,5,8}, so a(1)=5.
%p segments := proc (n)
%p local rr, x1, y1, x2, y2, sqDist;
%p rr := {};
%p for x1 from 0 to n do for y1 from 0 to n do
%p for x2 from 0 by -1 to -n do for y2 from 0 by -1 to -n do
%p sqDist := (x1-x2)^2+(y1-y2)^2;
%p if 0 < sqDist then rr := {op(rr), sqDist} end if;
%p end do end do
%p end do end do;
%p return rr
%p end proc:
%p qq:=[seq(nops(segments(n)), n=0..20)]
%K nonn
%O 0,2
%A _César Eliud Lozada_, Mar 15 2019
%E a(31)-a(48) from _Jon E. Schoenfield_, Apr 03 2019
|