Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save shockalotti/d29021387e8bb3875d28 to your computer and use it in GitHub Desktop.

Select an option

Save shockalotti/d29021387e8bb3875d28 to your computer and use it in GitHub Desktop.

Revisions

  1. shockalotti created this gist May 28, 2014.
    18 changes: 18 additions & 0 deletions Go Golang - recursive function, fibonacci sequence
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    package main

    import "fmt"

    func fib(n uint) uint {
    if n == 0 {
    return 0
    } else if n == 1 {
    return 1
    } else {
    return fib(n-1) + fib(n-2)
    }
    }

    func main() {
    n := uint(10)
    fmt.Println(fib(n))
    }