I've been searching for the answer for many years, both by researching by myself and reading about the subject. Now I'm wondering if this has a solution.

The problem can be stated as follows.

Given a M x N grid of points, how many triangles with vertices in the grid can be formed? Note that you can't select two points that coincide or three collinear points because that wouldn't conform a triangle (area would be 0)

OK, I know a bit of programming and could manage to code a program that solves this, but would REALLY like to know if there is a general form depending on M and N. I suspect it has to do with prime numbers... (Perhaps I totally missed heheh)

Thanks for your time! Manuel