Count points and lines in $\mathbb{A}^2(\mathbb{F}_p)$ Let $p$ be a prime, then $\mathbb{F}_p$ is a finite field.
$\mathbb{A}^2(\mathbb{F}_p)$ is an affine plane.
Number of points in $\mathbb{A}^2(\mathbb{F}_p)$ is $p^2$.
I look at a line equation $ax+by=c$ and realise that number of distinct lines equals to number of triples $(a,b,c)$, where $\gcd(a,b,c)=1,\ a,b,c \in [0,p-1]$.
The question is: how to count the triples?
 A: If you know about projective space, I think the easiest way is to count lines in the projective plane, and then subtract $1$ (for the line "at infinity", which you don't want to count).
By line-point duality, there are as many points as there are lines in $\mathbb{P}^2(\mathbb{F}_p)$ - and there are $p^2+p+1$ points in $\mathbb{P}^2(\mathbb{F}_p)$, because it is the disjoint union of the affine spaces of lesser or equal dimension. Thus there are $p^2+p$ lines in $\mathbb{A}^2(\mathbb{F}_p)$.
(The line-point duality comes from the fact that a line in $\mathbb{P}^2$ is given by a homogeneous equation $aX+bY+cZ=0$. It corresponds to the point $[a,b,c]$ in homogeneous coordinates.)
A: There are exactly $p$ lines that are parallel to the $y$-axis. Each of those is uniquely determined by the point of intersection with the $x$-axis.
All the other lines $y=mx+b$ are uniquley determined by their slope $m$ and intercept $b$. There are $p$ choices for both $m$ and $b$, so altogether we have $p^2$ lines that are not parallel to the $y$-axis.
Thus the answer is $p^2+p$.
A: I think what you want to do is to count the number of distinct lines. Your condition with the GCD only works when you are in $\mathbb Z$ or something like that. In $\mathbb F_p$ it's a little different. In the following I consider two lines to be the same if they have the same set of solutions, just to make sure I am clear.
There are $p$ lines of the form $ax = c$ and $a \neq 0$, because the set of solutions for those is just $(a^{-1} c, y)$ with $y$ ranging from $0$ to $p-1$ ; hence $a^{-1}c = A$ for some $A$ and the lines are just $(A,y)$ with $y \in \mathbb F_p$. There is also $p$ lines of the form $by = c$ with $b \neq 0$ for the same reasons. If $a=b=c=0$ then the line is the set of all couples $(x,y)$. If $a=b=0 \neq c$ then you get the empty line. Hence by considering $a=0$ or $b=0$ I got $2p+2$ lines. You distinguish what you consider a line or not in the latter. (You might not want to consider the empty line as a line.)
Assume from now on that $a \neq 0 \neq b$. A line of the form $ax + by = 0$ is always of the form $y = Ax$ with $A = b^{-1}a$. There are $p-1$ such lines, since $A$ can range from $1$ to $p-1$ and clearly all those lines are distinct.
It remains to consider the case where $c \neq 0$. In fact, if $ax + by = c$, then $y = Ax + C$, and by translating we have $y = A(x-A^{-1} C) + C = Ax - C + C = Ax$. Hence adding the constant $c$ gives us $p-1$ new lines for each value of $A$, and they are just translates of the old lines of the form $y=Ax$.
In the end, there are $(2p+2) + p(p-1) = p^2 + p + 2$ lines if you consider the empty set as a line, and $p^2 +p+1$ if you don't.
Hope that helps,
