%I #21 Jun 17 2024 15:25:29
%S 0,4,36,184,592,1828,4164,9360,18592,34948,59636,102096,161496,255700,
%T 385292,562336,796344,1131996,1552780,2133368,2855632,3765492,4876444,
%U 6328104,8049744,10203820,12766508,15870744,19496392,23984444,29090340,35318968,42535496,50936036
%N a(n) is the number of ways to select three distinct points of an n X n grid forming a triangle whose sides do not pass through a grid point.
%C a(n) is 1/6 of the number of ways to select three points (x,y), (u,v), (p,q) with gcd(x-u,y-v) = gcd(u-p,v-q) = gcd(p-x,q-y) = 1 and 0 <= x, y, u, v, p, q <= n in an n X n grid.
%H Felix Huber, <a href="/A372218/a372218.pdf">Illustration of a(2)</a>
%e See the linked illustration: a(2) = 36 because there are 36 ways to select three distinct points in a square grid with side length n that satisfy the condition.
%p A372218:=proc(n)
%p local x,y,u,v,p,q,a;
%p a:=0;
%p for x from 0 to n do
%p for y from 0 to n do
%p for u from 0 to n do
%p for v from 0 to n do
%p if gcd(x-u,y-v)=1 then
%p for p from 0 to n do
%p for q from 0 to n do
%p if gcd(x-p,y-q)=1 and gcd(p-u,q-v)=1 then a:=a+1 fi;
%p od;
%p od;
%p fi;
%p od;
%p od;
%p od;
%p od;
%p a:=a/6;
%p return a;
%p end proc;
%p seq(A372218(n),n=0..33);
%Y Cf. A115004, A141224, A141255, A320540, A320541, A320544, A372217.
%K nonn
%O 0,2
%A _Felix Huber_, Apr 28 2024