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