resursion _ golang

Go support recursive functions. Here's a classic factorial example

package main

import (
    "fmt"
)

func fact(n int) int {
    if n == 0 {
        return 1
    }
    return n * fact(n-1)
}

func main() {
    fmt.Println(fact(7))
}
5040

总结 :

  1 : 递归....

posted on 2015-03-14 17:32  xjk112  阅读(179)  评论(0编辑  收藏  举报