%I #27 Feb 11 2024 20:59:45
%S 0,0,40,368,1704,5704,15400,36096,75632,145968,263592,451392,738360,
%T 1163552,1774840,2632344,3808992,5394752,7493936,10233832,13759008,
%U 18241312,23877984,30896984,39551456,50137240,62983128,78459880
%N Number of scalene triangles on an n X n grid (or geoboard).
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Geoboard.html">Geoboard</a>.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/ScaleneTriangle.html">Scalene Triangle</a>.
%F a(n) = A045996(n) - A186434(n).
%t q[n_] :=
%t Module[{sqDist, t0, t1, t2},
%t (* Squared distances *)
%t sqDist = {p_, q_} :> (Floor[p/n] - Floor[q/n])^2 + (Mod[p, n] - Mod[q, n])^2;
%t (* Triads of points *)
%t t0 = Subsets[Range[0, n^2 - 1], {3, 3}];
%t (* Exclude collinear vertices *)
%t t1 = Select[t0, Det[Map[{Floor[#/n], Mod[#, n], 1} &, {#[[1]], #[[2]], #[[
%t 3]]}]] != 0 &];
%t (* Calculate sides *)
%t t2 = Map[{#,
%t Sort[{{#[[2]], #[[3]]}, {#[[3]], #[[1]]}, {#[[1]], #[[2]]}} /. sqDist]}&, t1];
%t (* Select scalenes *)
%t t2 = Select[t2,
%t #[[2, 1]] != #[[2, 2]] && #[[2, 2]] != #[[2, 3]] && #[[2,3]] != #[[2, 1]] &];
%t Return[Length[t2]];
%t ];
%t Map[q[#] &, Range[9]] (* _César Eliud Lozada_, Mar 26 2021 *)
%Y Cf. A045996, A186434.
%K nonn
%O 1,3
%A _Martin Renner_, May 08 2011