Wins the offer-03

Seeking 1 + 2 + 3 + ... + n, requires multiplication and division can not be used, for, while, if, else, switch, case and keywords such as conditional statement (A B:? C)

 

class Solution:
def Sum_Solution(self, n):
# write code here
return sum(list(range(1,n+1)));

Guess you like

Origin www.cnblogs.com/jeasonit/p/11714586.html