题解 | #求1+2+3+...+n#这不直接等差数列还等啥?
求1+2+3+...+n
http://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1
class Solution:
def Sum_Solution(self , n: int) -> int:
# write code here
res=((1+n)*n)//2
return res
求1+2+3+...+n
http://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1
class Solution:
def Sum_Solution(self , n: int) -> int:
# write code here
res=((1+n)*n)//2
return res
相关推荐