Skip to content

Commit 79e08d3

Browse files
Update 求平方根.md
1 parent ca344dd commit 79e08d3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Dichotomy/求平方根.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,28 @@ public class SquareRoot {
3131

3232
```
3333

34+
35+
36+
Go 语言:
37+
38+
```go
39+
package main
40+
41+
import "fmt"
42+
43+
func main() {
44+
num := 8
45+
target, left, right := float64(num), float64(0), float64(num)
46+
for right-left > 1e-7 {
47+
mid := (left + right) / 2
48+
if mid*mid > target {
49+
right = mid
50+
} else {
51+
left = mid
52+
}
53+
}
54+
fmt.Println(left)
55+
fmt.Println(right)
56+
}
57+
```
58+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy