Outils pour utilisateurs

Outils du site


tech:notes_-_algorithme

Notes - Algorithme

Go lang - newton - racine carré

package main
 
// Source : https://go.dev/tour/flowcontrol/8
 
import (
        "fmt"
)
 
func Sqrt(x float64) float64 {
        z := 1.0
        for range 10 {
                z -= (z*z - x) / (2 * z)
        }
        return z
}
 
func main() {
        fmt.Println(Sqrt(2))
}
tech/notes_-_algorithme.txt · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki