Skip to content

Commit

Permalink
Merge pull request #231 from hurlenko/approx_phi_go
Browse files Browse the repository at this point in the history
Add phi approximation in Go
  • Loading branch information
wzhouwzhou authored Oct 31, 2018
2 parents 2e2f063 + afc3b84 commit cdf029b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions go/approximate_phi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"fmt"
)

func main() {
fmt.Println(phi(1000)) // number of iterations
}

func phi(args... float64) float64 { if iters := args[0]; iters > 0 { return func() float64 { if len(args) == 1 { return phi(iters - 1, 1 + 1.0 / 1)} else {return phi(iters - 1, 1 + 1.0 / args[1])} }()} else { return args[1]}}

0 comments on commit cdf029b

Please sign in to comment.