Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Created July 24, 2014 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradoyler/0d35719fef87916023dd to your computer and use it in GitHub Desktop.
Save bradoyler/0d35719fef87916023dd to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func main() {
fmt.Println("ack(3, 4):", ack(3, 4))
}
func ack(m, n int) (result int) {
if m == 0 {
result = n + 1
} else if m > 0 && n == 0 {
result = ack(m-1, 1)
} else if m > 0 && n > 0 {
result = ack(m-1, ack(m, n-1))
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment