hypotenuse function

num hypotenuse(
  1. num x,
  2. num y
)

Calculates the hypotenuse of a right-angled triangle given the lengths of the other two sides.

This function uses the Pythagorean theorem to compute the hypotenuse.

param x The length of one side of the triangle. param y The length of the other side of the triangle. returns The length of the hypotenuse.

Implementation

num hypotenuse(num x, num y) {
  return math.sqrt(math.pow(x, 2) + math.pow(y, 2));
}