GITLAB

Nattapon Wongpaet / mockup-api

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • mockup-api
  • main.go
  • ea230db8   update mockup Browse Code ยป
    Nattapon W
    2022-03-28 10:31:11 +0700  
main.go 310 Bytes
Edit Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package main

import (
	"fmt"
	"math"
)

func findRoots(a, b, c float64) (float64, float64) {

	x1 := ((-b) + math.Sqrt(math.Pow(b, 2)-(4*a*c)))/(2*a)
	x2 := ((-b) - math.Sqrt(math.Pow(b, 2)-(4*a*c)))/(2*a)

	return x1, x2
}

func main() {
	x1, x2 := findRoots(2, 10, 8)
	fmt.Printf("Roots: %f, %f", x1, x2)
}