I have the following problem to solve in Mathematica, but (maybe because of my inexperience) it seems quite a really one to code properly.
Given a line $y=mx+q$ with $q>0$ and $m<0$, this intersects the positive $x$-axis and a positive $y$-axis to form a rectangular triangle in the first quadrant.
I would like to find an algorithm that will allow me to write all the integral points $(x,y)$ contained inside of such triangle (or on in boundary) in function of $m$ and $q$. With integral points I mean points such that $x$ and $y$ are integer numbers. Furthermore (an this is crucial) I would like to have the set of coordinates of such output points as entries of a list.
So far I can solve the problem via a nested "while cycle" but the output is not a list, rather it is many cells, each one printing the coordinates of one point inside.
Any suggestions?
{x, y} /. {ToRules[Reduce[y < 11 - 7 x && x > 0 && y > 0, {x, y}, Integers]]}
? $\endgroup$Graphics[Point /@ %]
$\endgroup$Flatten[Table[ {x, y}, {x, 0, -q/m} , {y, 0, m x + q }], 1]
$\endgroup$