Skip to content

Commit

Permalink
Add phi approximation in Go
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Oct 30, 2018
1 parent 67d5e8c commit afc3b84
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 afc3b84

Please sign in to comment.