其他分享
首页 > 其他分享> > #力扣 LeetCode剑指 Offer 64. 求1+2+…+n @FDDLC

#力扣 LeetCode剑指 Offer 64. 求1+2+…+n @FDDLC

作者:互联网

题目描述:

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

 

Java代码:

class Solution {
    public int sumNums(int n) {
        boolean b=n!=0&&(n=n+sumNums(n-1))==0;
        return n;
    }
}

 

 

 

 

 

 

 

 

 

 

 

 

标签:Java,cn,int,sumNums,12n,力扣,boolean,64,FDDLC
来源: https://blog.csdn.net/liuxc324/article/details/113467142