Skip to content

Commit

Permalink
Merge bba9930 into 9c5596e
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas committed Feb 20, 2016
2 parents 9c5596e + bba9930 commit e4b1c80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ language: go

go:
- 1.5
- 1.6

install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
- go get github.com/pierrre/gotestcover
- go get -t ./...
- go get -t .

script:
- gotestcover -coverprofile="cover.out" -race -covermode="count" ./...
- gotestcover -coverprofile="cover.out" -race -covermode="count" .

after_success:
- goveralls -coverprofile="cover.out"
10 changes: 3 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,15 @@ func ComputePi(rw http.ResponseWriter, r *http.Request) {
// pi launches n goroutines to compute an
// approximation of pi.
func pi(n int) float64 {
ch := make(chan float64)
for k := 0; k <= n; k++ {
go term(ch, float64(k))
}
f := 0.0
for k := 0; k <= n; k++ {
f += <-ch
f += term(float64(k))
}
return f
}

func term(ch chan float64, k float64) {
ch <- 4 * math.Pow(-1, k) / (2 * k + 1)
func term(k float64) float64 {
return 4 * math.Pow(-1, k) / (2*k + 1)
}

var thisID = uuid.New()
Expand Down

0 comments on commit e4b1c80

Please sign in to comment.