Problem 44476. How many unique Pythagorean triples?
For a given integer n, return all Pythagorean triples that inlude numbers smaller or equal to n.
A Pythagorean triple consist of three positive integers {a, b, c} such that:
a < b < c, a^2 + b^2 = c^2
The triples should be retured in a matrix with tree columns, where each row contains a different triple. Every row needs to be sorted in ascending order ( a in the first column, b in the second and c in the third), and the first column must also be sorted.
Example:
Input: n = 16 Output: mat = [3, 4, 5 5, 12, 13 6, 8, 10 9, 12, 15]
If n is not an integer, or it is smaller than 5, the function should return an empty matrix.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers143
Suggested Problems
-
Find state names that end with the letter A
1151 Solvers
-
7913 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
10274 Solvers
-
Circular Primes (based on Project Euler, problem 35)
469 Solvers
-
Find out sum and carry of Binary adder
1338 Solvers
More from this Author25
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!