How do I find points on the line segment joining {-4, 11} and {16, -1} whose coordinates are positive integers?
|
|
|||||||
|
|
Is this what you are searching for?
|
|||
|
|
|
There are many ways to proceed, the best one uses I Since we know, that
we find
a bit more straightforward way : II
|
|||||||||||||
|
|
You can also use
All three give
To show in a plot:
Update: You can also use the plain old
Update 2: Getting into
or
|
|||||||||||
|
|
Artes's solution is the best, I think. If you just want to treat this as an ordinary Diophantine problem, you can do that with
One could also choose to use Bézout's identity to solve this problem (see for instance this excellent math.SE post by Arturo Magidin). Luckily,
We check something first:
So a particular solution is then given by
We can derive a parametrized set of solutions like so:
As it turns out,
|
|||
|
|
This solution shows how to transform linear complexity to quadratic, and provides some relief of the comic variety. ;) |
|||
|
|
|
Suppose we know the equation of line through the two points, one can generate all points on the line with integer
Put this in
|
||||
|
|


