Obtain number of pieces in jigsaw puzzle from its ratio of border pieces My daughter was given an intriguing math assignment. I found a solution, but I'm curious about a more elegant approach.
"A jigsaw puzzle of M by N pieces has exactly 8% of border pieces. What are M and N ?"
The pieces are arranged in a perfect rectangular grid, and there's no funny stuff with irregular shapes. Therefore, the total amount of pieces is simply $M.N$ ; whereas the pieces on each of the 4 edges can be counted as $2.(M+N)$, but that counts the four corners twice. Correcting for this, my equation becomes $2.(M+N)-4=(8\%).M.N$ which simplifies to :
$$M+N-2 = \frac{M.N}{25}$$
That's where the elegance stops and my crude guesswork begins, while the assignment explicitly asks not to use trial-and-error.
Focusing on the fact that M and N need to be integers, I briefly pondered $25|M$ but I concluded that won't yield any viable solutions for $N$. So I went for the more balanced constraints $5|M\;\&\;5|N$. I decided to rewrite the variables as $M=5.m$ and $N=5.n$ to ultimately get to the equation :
$$5.(m+n)-2=m.n$$
I believe that "Integer calculus" exists as a branch of mathematics, but it is entirely shrouded in mystery to me. So I resorted to brute-force, and I listed all the integer multiples of 5, minus 2, to represent the left side of the equation : $13,18,23,28,33,...$ Then I tried to factor each of these numbers into $m.n$ to make the equation work out.
As is to be expected, this could be charted as a race between a steep linear graph, and a parabole. When aiming for a nearly square jigsaw puzzle by choosing $m\approx n$, the five-fold sum at the left of the equation, starts out much larger than the product at the right. I found the parabole to be overtaking the straight line around $m+n=21$ without yielding an integer solution ; from there on, the value of the parabole becomes way too large to ever obtain any further solutions.
However, not all the factorings of my series $13,18,23,28,33,...$ have a near-square aspect ratio. When the product can be factored into more than two divisors, the aspect ratio $m/n$ can be tailored at will. By going for $m<<n$ (which a physicist might call sacrificing surface area for perimeter length), additional paraboles for $m.n$ appear on the chart, intersecting the linear graph for $5.(m+n)-2$ elsewhere. This eventually led me to an integer solution for $m$ and $n$, which I converted back to $M$ and $N$ to get to a sizeable jigsaw puzzle.
I can't imagine that this would be the approved method, so I might actually flunk my daughter's assignment. How would a real mathematician handle this task ?
 A: Concerning the equation $5(m+n)-2=mn$, here is an approach: we have
$$n = \frac {5m-2}{m-5}=5+\frac{23}{m-5}$$
This shows that $(m-5)\mid 23$.
Since $23$ is prime, $m-5 = 1$ or $23$. (or $-1$ or $-23$, but these values don't give positive $m$ or $n$)
We thus have $m = 6$ or $28$.
For $m=6$, $n=28$. For $m=28$, $n=6$.
EDIT: by the way there are solutions for $25\mid M$ which you can similarly find:
$M=50, N=48$ and $M=600,N=26$.
A: I want to post a bit more clear version of @player3236's solution in that way that we have considered all possible $(N,M)$ pairs. Indeed, we re-write
$$M+N-2=\frac{MN}{25}\Leftrightarrow 25(M+N-2)=MN\\
\Leftrightarrow N(M-25)=25(M-2)\Leftrightarrow
N=\frac{25M-50}{M-25}\\
\Leftrightarrow N-25=\frac{575}{M-25}$$
As $575=5^2\cdot 23$ we can factor $575$ into product of two integers in $12$ ways:
$M-25=1,\,N-25=575\Rightarrow M=26,\,N=600$
$M-25=5,\,N-25=115\Rightarrow M=30,\,N=140$
$M-25=23,\,N-25=25\Rightarrow M=48,\,N=50$
$M-25=25,\,N-25=23\Rightarrow M=50,\,N=48$
$M-25=115,\,N-25=5\Rightarrow M=140,\,N=30$
$M-25=575,\,N-25=1\Rightarrow M=600,\,N=26$
$M-25=-1,\,N-25=-575\Rightarrow M=24,\,N=-550$
$M-25=-5,\,N-25=-115\Rightarrow M=20,\,N=-90$
$M-25=-23,\,N-25=-25\Rightarrow M=2,\,N=0$
$M-25=-25,\,N-25=-23\Rightarrow M=0,\,N=2$
$M-25=-115,\,N-25=-5\Rightarrow M=-90,\,N=20$
$M-25=-575,\,N-25=-1\Rightarrow M=-550,\,N=24$
So all positive integer solutions are indeed $(26,600),\,(30,140),\,(48,50)$ up to permutations.
