[Math] Are there prime lengths in triangle with all integer sides and heights

geometryprime numberstriangles

Suppose you have a triangle in which all sides and all heights are integer in length (i.e. triangle with sides 20, 25, 15 has heights 15, 12 and 20). Could it be that at least one of those numbers is prime?

It is very easy to prove that if the numbers are all different then at most 3 of them could be prime. Suppose that $a$, $b$ and $c$ are sides and $h_{a}, h_{b}$ and $h_{c}$ are corresponding heights. Then double area of the triangle is $a h_{a} = b h_{b} = c h_{c}$. If there are 4 or more prime numbers then one equation would be product of two prime numbers (by pigeonhole principle), but by fundamental theorem of arithmetic there is only a single way to express the number as product of primes which contradicts the preposition that all numbers are different. This is fairly weak result, but result nonetheless.

I dug a bit further and (according to Wolfram Mathworld) the triangle which has all integer sides and integer area is called a Heronian triangle (all 'our' triangles are Heronian, but not all Heronian triangles are 'our'). At that page there is a generative formula which immediately$^{*}$ shows that none of sides can be prime, and quite obviously height opposing $c$ can't be prime. I haven't got far trying to prove that other two heights can't be prime either, but I've written a small script which iterates m, n and k up to 500 and yet to find any prime numbers (so far 270K triangles out of 61M triples I intend to iterate over, 54M to go).

[*] On 'immediately':
Originally I claimed that sides can't be prime because they are products of integer numbers. In comments Steven Stadnicki raised the point that $m$ or $n$ (or both) can be equal to 1 which would lead to possibility of prime sides. I've shown that this is impossible to have prime side with that condition. Here is the copy of generative formulas from that page for reference:

$a = n(m^{2}+k^{2})\\
b = m(n^{2}+k^{2})\\
c = (m+n)(mn-k^{2})\\
S = kmn(m+n)(mn-k^{2})\\
GCD(m,n,k) = 1; mn > k^{2} \ge m^{2}n/(2m+n); m \ge n \ge 1$

First we can easily see that both $m$ and $n$ can't be 1 (as $mn > k^{2}$), so only $n$ can be 1, and $m \ge 2$. I'm going to prove that if $n=1$ and $a$ is prime ($b$ is definitely composite) then $h_{a}$ is not integer, thus that triangle is not conforming.
Let $a = p$, where $p$ is prime and $n = 1$. Then $h_{a} = 2S/p = 2km(m+1)(m-k^{2})/p$.

For $h_{a}$ to be integer there should be at least one factor in numerator which is divisible by $p$. Thus one of following should be true (where $q$ is a natural number):

$\tag{a} 2=q(m^{2}+k^{2})$
$\tag{b} k=q(m^{2}+k^{2})$
$\tag{c} m=q(m^{2}+k^{2})$
$\tag{d} m+1=q(m^{2}+k^{2})$
$\tag{e} m-k^{2}=q(m^{2}+k^{2})$
As $m \ge 2$ it is obvious that (a) can't be true. The rest all lead to quadratic equations, which have no suitable integer solutions. For example let's take (e) and try to solve for $m$: $0 = qm^{2}-m+k^{2}(1+q)$, discriminant is $1-4qk^{2}(1+q)$ which is negative for any natural $q$ and $k$, thus there no such $m$. Similar results can be given for other equations, which means that there is no such number $p$ that $h_{a}$ is integer.

Proof that $mn-k^{2}=1$ leads to non-integer $h_{a}$ is similar, thus $c$ can't be prime either.

Best Answer

No, none of the lengths can be prime.

Let me write $d,e,f$ for $h_a,h_b,h_c$, then twice the area is $$ 2\mathrm{Area} = ad=be=cf $$

triangle

Furthermore let $c=x+y$ with $x,y$ possibly signed lengths satisfying $x^2+f^2=a^2$ and $y^2+f^2=b^2$, so $x,y$ are (possibly signed) integers.

Consider the case in which a side length is prime, wlog let it be $c$.

Then since $c>d$, $c\nmid d$, but $c\mid ad$ so we must have $a=tc$, and similarly $c>e$ so $b=uc$ for integers $t,u$. Since $a,b,c$ make a triangle $a<b+c$ and $b<a+c$ we have $t<u+1,u<t+1\implies t=u$ and the triangle must be isosceles with $a=b$.

Then $x=y=c/2$, but $a^2=f^2+x^2$ requires $x$ to be an integer, so $c$ is even and can only be prime if $c=2$. But then $a^2=f^2+1$ which is impossible for positive integers $a,f$, so there cannot be such a triangle with a prime side.

Consider the case in which a height is prime, wlog let it be $f$.

If $f\mid a$ then $f\mid x$ and $(x/f)^2+1=(a/f)^2$ which is impossible for nonzero integers $x/f,a/f$. So $f\nmid a$ and $f\mid ad \implies d=tf$. Similarly $f\nmid b$ and so $e=uf$. Then from $ad=be=cf$ we have $c=ta=ub$. Wlog $a\ge b$, then from $c<a+b$ we have $(t-1)a<b \implies t=1$ and the triangle must be isosceles with $a=c$.

Then with $c=ub,e=uf$ and by symmetry the altitude bisecting $b$ $$ (b/2)^2+e^2=c^2 \\ (b/2)^2+u^2f^2=u^2b^2 \\ f^2=\left(\frac{b}{2u}\right)^2(4u^2-1) $$ Since $f$ is an integer and $\gcd(2u,4u^2-1)=1$ we must have $2u\mid b$. Since we have already shown $f\nmid b$ and by assumption $f$ is prime, then $\gcd(f,b)=1$ and we must have $b/2u=1$. Then $f^2=4u^2-1$, but this is impossible for positive integers $u,f$, so there cannot be such a triangle with prime height.