CodePudding user response:
sum=0
A=int (input (" please enter a number, calculates the 1 + 2 +.. + n \ n "))
For I in range (a + 1) :
The sum +=I
Print (" 1 + 2 +... + % % d=% d "(a sum))
Please enter a number, calculates 1 + 2 +... + n
5
1 + 2 +... + 5=15
CodePudding user response:
Sum1=0Num=int (input (' input integer: '))
Print (num, sum (the list (I for I in range (1, num + 1))))