%I #28 May 16 2020 03:47:07
%S 0,0,1,2,5,9,17,25,39,55,77,99,131,165,211,257,311,369,443,517,609,
%T 705,813,921,1051,1185,1339,1493,1665,1843,2049,2255,2491,2735,2999,
%U 3263,3551,3845,4175,4505,4859,5221,5623,6025,6469,6923,7401,7879,8403,8935,9509
%N Draw the lines with equations y=kx (k=1..n) on the R^2/Z^2 square flat torus. a(n) is the number of intersection points.
%C It appears that the second differences of this sequence yield A326305.
%H Luc Rousseau, <a href="/A334087/a334087.png">Illustration of the fact that a(7) = 25</a>
%o (PARI)
%o f(i,j,c,d)=my(L=List(),x,y);x=(d-c)/(j-i);if(max(c/i,d/j)<=x&&x<min((c+1)/i,(d+1)/j),y=(d*i-c*j)/(j-i);listinsert(L,[x,y],1));L
%o g(i,j)=my(c,d,L,S=Set());for(c=0,i-1,for(d=c+1,j-1,L=f(i,j,c,d);S=setunion(S,Set(L))));S
%o h(n)=my(i,j,S=Set());for(i=1,n-1,for(j=i+1,n,S=setunion(S,g(i,j))));S
%o a(n)=(n>1)+#h(n)
%o for(n=0,60,print1(a(n), ", "))
%Y Cf. A326305.
%K nonn
%O 0,4
%A _Luc Rousseau_, Apr 15 2020