码迷,mamicode.com
首页 > 其他好文 > 详细

resursion _ golang

时间:2015-03-14 18:18:24      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:

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 : 递归....

resursion _ golang

标签:

原文地址:http://www.cnblogs.com/jackkiexu/p/4337898.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!