Le Monde puzzle [#1062]
[This article was first published on R – Xi'an's Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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
To leave a comment for the author, please follow the link and comment on their blog: R – Xi'an's Og.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.