Back

Write a code to get an integer N and print the sum of  values from 1 to N. Input Description: A single line contains an integer N. Output Description: Print the sum of values from 1 to N. Sample Input : 10 Sample Output : 55

Created 2 years ago
692 Views
2 Comments
KRajesh
@KRajesh
KRajesh
@KRajeshProfile is locked. Login

Below is my code-

num = int(input())

sum = 0

for i in range(num+1):

sum = sum+1

print(sum)

but i got the input as 11 in codekata but 55 in jupyter notebook.

Comments (2)
Please login to comment.