求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) }
求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) }