# Finding positive integer triples $(m,n,r)$ with $\frac{mr}{m+n}$ being an integer and $r-n > \frac{mr}{m+n}-1$ and $r\le \max{(m,n)}$ [closed]

I would like to use Mathematica to find all positive integer triples $$(m,n,r)$$ satisfying

(1) $$\frac{mr}{m+n}$$ is an integer;

(2) $$r-n > \frac{mr}{m+n}-1$$;

(3) $$r\le \max{(m,n)}$$;

(4) $$1\le m < 1000$$, $$1\le n < 1000$$, $$1\le r < 1000$$, all integers.

The code I use is:

   FindInstance[m*r ==(m+n)*s && r-n > m*r/(m+n)-1 && r <= Max[m,n] && 0<m<1000 && 0<n<1000 && 0<r<1000, {m,n,r,s}, Integers]


But I got an error that I don't understand Update: As pointed by azerbajdzan, I should use Max instead of FindMaximum (corrected above for convenience of future reference.) I will still happy to see anyone who could improve the code, making it run faster.

• Use Max instead of FindMaximum. Sep 26, 2022 at 19:34
• @azerbajdzan thanks! No solution then?? Sep 26, 2022 at 19:39
• If empty list was returned then no solution - I have not run the code myself. Sep 26, 2022 at 19:48
• Condition (2) says r-n>m*r/(m+r)-1 but your code says r-n>m*r/(m+n)-1. Sep 26, 2022 at 19:55
• @user293787 Thanks a lot! Problem with my condition Sep 26, 2022 at 20:04

Since m*r/(m+n) == s, we replace  r - n > m*r/(m + n) - 1 with  r - n > s - 1

Reduce[{m*r == (m + n)*s, r - n > s - 1,
r <= Max[m, n], {m, n, r} > 0}, Integers]


False.

FindInstance[{m*r == (m + n)*s, r - n > s - 1,
r <= Max[m, n], {m, n, r} > 0}, {m, n, r, s}, Integers]


{}

It means that there are no solution satisfies the conditions.