package main
import "fmt"
func Recursive(n int) int {
if n == 0 {
return 1
}
//相当于10987654321
return n Recursive(n-1)
}
func main() {
fmt.Println(Recursive(10))
}
执行结果:
sf@SFdeMacBook-Pro ~/Documents/project/src/test go build Recursive.go
sf@SFdeMacBook-Pro ~/Documents/project/src/test ./Recursive
3628800
有疑问加站长微信联系(非本文作者)