Pythagorean Triplet

Published by Deep Xavier in

Create a function that validates whether the three given integers form a Pythagorean triplet which is defined as the sum of the squares of the two smallest integers must be equal to the square of the largest integer.

Examples

isTriplet(3, 4, 5) ➞ true
// 3² + 4² = 25
// 5² = 25

isTriplet(13, 5, 12) ➞ true
// 5² + 12² = 169
// 13² = 169

isTriplet(1, 2, 3) ➞ false
// 1² + 2² = 5
// 3² = 9

isTriplet(72, 54, 90) ➞ true

isTriplet(54, 46, 77) ➞ false

isTriplet(80, 48, 64) ➞ true

Notes

  • Numbers may not be given in a sorted order.
Watch a quick demo on how Edabit works.