递归函数
求1-10的和
func sum(num int) int { if num == 1 { return 1 } return sum(num-1) + num } func main() { ret := sum(10) fmt.Println(ret) }
Welcome to visit
求1-10的和
func sum(num int) int { if num == 1 { return 1 } return sum(num-1) + num } func main() { ret := sum(10) fmt.Println(ret) }