輸入一個數字n,計算1+2+3+...+n的總和為多少? (for 迴圈版本) n = int(input('Please input n:')) sum = 0 for i in range(1,n+1): # sum += i print('Sum is:',sum).
確定! 回上一頁