This is a mathematic problem rather than a coding one.
If
a
and
b
are the sides of the right triangle and
c
its hypothenuse, the following relations stand:
c² = a² + b² => c = sqrt(a² + b²)
a² = c² - b² => a = sqrt(c² - b²)
b² = c² - a² => b = sqrt(c² - a²)