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
转载于:https://blog.51cto.com/jiekeyang/2178875