for i in range(1,101): theSum += i print("1-100的和:",theSum) #2.求300-400的和 theSum = 0 for i in range(300,401): theSum += i print("300-400的和:",theSum) #3.求1-1000的和 theSum = 0 for i in range(1,1001): theSum += i print("1-1000的和:",theSum) 1....
怎么用递归python计算1到n的和 python用递归方法求1到100的和,#递归算法求和1-100defqiehe():defhe(lis):iflis==[]:return0returnlis[0]+he(lis[1:len(lis)])s=[]n=input("请输入数字:")foriinrange(1,int(n)):s.append(i)print(he(s))