<s>[INST] How many distinct straight lines can be formed that are given by equation $ax + by = 0$, where $a$, $b$ are numbers from the set {$0,1,2,3,4,5,6,7$}? My answer is 37.

*

*If $a = 0$, then only possible equation is $ y= 0$

*If $b = 0$, then only possible equation is $ x= 0$
For {$1,2,3,4,5,6,7$}, possible pairs are $7*7 = 49$. Therefore, $49+2 = 51$ equations in total but it includes several repeats:

*

*$(1,1), ..., (7,7)$ are all $x + y = 0$. Therefore, $51 - 6 = 45$

*$(1,2), (2,4), (3,6)$ are all $x + 2y = 0$. Therefore, $45 - 2 = 43$

*$(1,3), (2,6)$ are all $x + 3y = 0$. Therefore, $43 - 1 = 42$

*$(2,1), (4,2), (6,3)$ are all $2x + y = 0$. Therefore, $42 - 2 = 40$

*$(2,3),(4,6)$ are all $2x + 3y = 0$. Therefore, $40 - 1 = 39$

*$(3,1),(6,2)$ are all $3x + 1y = 0$. Therefore, $39 - 1 = 38$

*$(3,2),(6,4)$ are all $3x + 2y = 0$. Therefore, $38 - 1 = 37$
Thus, we can make $37$ unique equations.
Is my reasoning correct? Is there any generalized/better method available?
 [/INST] $37$ is the right answer. Here is how I approached it -
The given equation is $ax + by = 0$; $a, b \in (0, 7)$
$(a)$ Let's start with $a = 1$. All eight values of $b$ give unique lines. Similarly for $b = 1$, we get eight unique lines but $a = b = 1$ is counted twice. That leads to $15$ unique lines.
$(b)$ Then for $~2 \leq a, b \leq 7$, we choose  $a$ and $b$ such that they are relatively prime, otherwise they would give lines already counted in $(a)$.
So,
For $a = 5, 7$, we have five value of $b$.
For $a = 3$, we have four values of $b$.
For $a = 2, 4$, we have three values of $b$.
For $a = 6$, we have two value of $b$.
That leads to number of unique lines as $~15 + 22 = 37$
</s>