Le Monde puzzle [#1062]
A simple Le Monde mathematical puzzle none too geometric:
- Find square triangles which sides are all integers and which surface is its perimeter.
- Extend to non-square rectangles.
No visible difficulty by virtue of Pythagore’s formula:
for (a in 1:1e4) for (b in a:1e4) if (a*b==2*(a+b+round(sqrt(a*a+b*b)))) print(c(a,b))
produces two answers
5 12 6 8
and in the more general case, Heron’s formula to the rescue!,
for (a in 1:1e2) for (b in a:1e2) for (z in b:1e2){ s=(a+b+z)/2 if (abs(4*s-abs((s-a)*(s-b)*(s-z)))<1e-4) print(c(a,b,z))}
returns
4 15 21 5 9 16 5 12 13 6 7 15 6 8 10 6 25 29 7 15 20 9 10 17
July 29, 2018 at 1:44 am
The solution is incorrect. The sum of two sides of a triangle is always greater than the third side. The solutions (4 , 5,21) , ( 5,9,16) and (6,7,15) do not form triangles. Replace the for loop for z by for (z in b:(a+b-1))
July 30, 2018 at 1:08 pm
Thanks, this should indeed have been added to the condition…