An Almost Pythagorean Triple (abbreviated as "APT'), is a set of 3 integers in which square of the largest element, which we will call as its 'hypotenuse', is 1 less than the sum of square of the smaller elements (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 triple , with and perimeter (the sum of the 3 elements) of . Some researchers consider as the smallest , but here, we will only look at 's where the hypotenuse is "strictly" greater than the other shorter sides. Other examples of 's are , and .
Unfortunately, unlike Pythagorean Triples, 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 between the hypotenuse and the shortest side: .
Given the value of r, find the perimeter of the with the r-th smallest perimeter. For example for , that is , the smallest perimeter is for , while the second (r-th) smallest perimeter is , for the with dimensions . For , the third smallest perimeter is for .
The output can be very large, so please present only the last 12 digits if the number of digits of the perimeter exceeds 12.

Solution Stats

19 Solutions

5 Solvers

Last Solution submitted on Jan 17, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...