https://leetcode-cn.com/problems/que-shi-de-shu-zi-lcof/submissions/

https://leetcode-cn.com/problems/qiu-12n-lcof/solution/qiu-12n-by-leetcode-solution/

天秀

题目描述

解题思路

func sumNums(n int) int {
    sum := 0
    var res func(int) bool
    res = func(n int) bool {
        sum += n
        return n > 0 && res(n-1)
    }
    res(n)
    return sum
}

总结

这种题目其实挺无聊的。。语言特性本来也不是刷题的本意。。