← Back to challenges

Pythagorean Triples Subset

PythonHardalgebrageometrynumbers

Instructions

A Pythagorean Triple is comprised of three positive integers, a, b, c, such that a**2 + b**2 = c**2. One special case is when a and b differ by only 1. The first five examples of this are:

(3, 4, 5), (20, 21, 29), (119, 120, 169), (696, 697, 985), (4059, 4060, 5741)

Devise a function that takes an integer n and returns the nth member of this sequence.

Examples

triple(1) ➞ (3, 4, 5)

triple(4) ➞ (696, 697, 985)

triple(10) ➞ (27304196, 27304197, 38613965)

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.