A Nearly Pythagorean Triangle (abbreviated as "NPT'), is an integer-sided triangle whose square of the longest side, which we will call as its 'hypotenuse', is 1 more than the sum of square of the shorter sides. This means that if c is the hypotenuse and a and b are the shorter sides,
, satisfies the following equation:
where: 
The smallest
is the triangle
, with
. Other examples are
,
, and
.
Unfortunately, unlike Pythagorean Triangles, a 'closed formula' for generating all possible
's, has not yet been discovered, at the time of this writing. For this exercise, we will be dealing with
's with a known ratio of the shorter sides:
.
Given the value of r, find the
with the second smallest perimeter. For example for
, that is
, the smallest perimeter is
, while the second smallest perimeter is
, for the
with dimensions
. Please present your output as vector
, where a is the smallest side of the
, and c is the hypotenuse.
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers22
Suggested Problems
-
Remove all the words that end with "ain"
2677 Solvers
-
Find state names that end with the letter A
1198 Solvers
-
Extract Built In Functions and Toolbox Functions from String or Function Handle
83 Solvers
-
Pandigital Multiples of 11 (based on Project Euler 491)
55 Solvers
-
Count unique orderings of vertices of a polygon
22 Solvers
More from this Author116
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!