0
$\begingroup$

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

enter image description here


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.

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

1 Answer 1

3
$\begingroup$

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.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.