## Le Monde puzzle [#1062] A simple Le Monde mathematical puzzle none too geometric:

1. Find square triangles which sides are all integers and which surface is its perimeter.
2. 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))```

``` 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
```

### 2 Responses to “Le Monde puzzle [#1062]”

1. Rajendra Bajpai Says:

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))

• xi'an Says:

Thanks, this should indeed have been added to the condition…

This site uses Akismet to reduce spam. Learn how your comment data is processed.