Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to count the number of triangles formed in a grid of $n\times n$ with positive integer coordinates $(0..n)$. For example for $n = 1$ the answer is 4.

share|cite|improve this question
$0$ isn't a positive integer! – Qiaochu Yuan May 31 '12 at 6:03
I think exact formula may be very hard. The problem is dealing with lines that pass through $3$ or more lattice points. This is sensitive to number-theoretic properties of $n$. – André Nicolas May 31 '12 at 6:03
Calculate it for some small values of $n$, and look it up in the Online Encyclopedia of Integer Sequences. – Gerry Myerson May 31 '12 at 11:45
@Qiaochu, I have read that in France, zero is considered to be positive. – Gerry Myerson May 31 '12 at 11:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.