Golang. Pythagoras Theorem


Continue practicing Go and remembering the school curriculum “Pythagoras pants are equal on all sides!” Or to paraphrase in a more boring version: the square of the length of the hypotenuse of a right triangle is equal to the sum of the squares of the cathetuses: c^2 = a^2 + b^2

Our titanic task is this: find the third side of a right triangle. Here’s the code:

package main

import (
	"fmt"
	"math"
)

func main() {

	var r float64 = 5
	var l float64 = 7

	// s^2 = r^2 + l^2

	s := math.Sqrt(math.Pow(r, 2) + math.Pow(l, 2))

	fmt.Println(s)
}

In next post we will check is point exists in the circle?


This entry was posted in Go (en). Bookmark the permalink.

Leave a Reply

🇬🇧 Attention! Comments with URLs/email are not allowed.
🇷🇺 Комментарии со ссылками/email удаляются автоматически.