Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 35
N=100 sum=0 for i in range(1, N+1): sum+=i print(sum) If we input 100 the result is 5050
1st Mar 2021, 5:11 PM
Yogesh Singh
Yogesh Singh - avatar
+ 19
Ilyass Nafi Try this: N = int(input()) #your code goes here num_list = list(range(N+1)) print(sum(num_list))
2nd Mar 2021, 6:04 AM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 12
N = int(input()) sum=0 for i in range(1, N+1): sum+=i print(sum)
30th Mar 2021, 2:54 PM
Thuvethika Selvanathan
+ 7
N=int(input()) sum=0 for i in range(1,N+1): sum+=1 print(sum)
11th Apr 2021, 7:13 AM
Susmitha S
Susmitha S - avatar
+ 3
N = int(input()) the_sum= sum(list(range(N+1))) print(the_sum)  consider this story about the mathematician Carl Friedrich Gauss. When Gauss was a boy, a teacher wanted to give the class some busywork. The teacher told them to add up all the numbers from 0 to 100. Young Gauss came up with a clever trick to figure out the answer in a few seconds, but you can write a Python program with a for loop to do this calculation for you.  total = 0  for num in range(101):      total = total + num  print(total) (Young Gauss figured out a way to solve the problem in seconds. There are 50 pairs of numbers that add up to 101: 1 + 100, 2 + 99, 3 + 98, and so on, until 50 + 51. Since 50 × 101 is 5,050, the sum of all the numbers from 0 to 100 is 5,050. Clever kid!)
21st Apr 2021, 6:02 AM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
+ 2
print(sum([x for x in range(N+1)]))
2nd Mar 2021, 10:05 PM
Andrew Smith
Andrew Smith - avatar
+ 2
Andrew Malenga You should post your problem in Q&A Section. And show your attempts.
25th Apr 2021, 12:38 AM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 1
https://www.dynamiccoding.tech/JUMP_LINK__&&__python__&&__JUMP_LINK-iterative-structure-python-loops/ Check out this blog so you will understand the working of range function and also get where do we add 100
2nd Mar 2021, 4:13 AM
Yogesh Singh
Yogesh Singh - avatar
+ 1
num = int(input()) nums = list(x for x in range(1, num+1)) print(sum(nums))
2nd Mar 2021, 12:40 PM
Nothing
Nothing - avatar
+ 1
n=int(input()) sum=0 for i in range(1,n+1): sum+=i print(sum)
15th May 2021, 12:33 PM
shivani bhavsar
shivani bhavsar - avatar
+ 1
num_list = list(range(N+1)) print(sum(num_list))
28th Aug 2021, 9:49 AM
PRINCE KUMAR
PRINCE KUMAR - avatar
+ 1
Try this N=int(input()) Print(int(N*(N+1)/(2)))
29th Aug 2021, 2:32 PM
Mir Shahzad Mubeen
0
Yes, but I forgot it. I was remembering it. Give it to me, please 
1st Mar 2021, 12:03 AM
ilyass nafi
ilyass nafi - avatar
0
N=int(input()) sen=0 for i in range(1,N+1): sen+=i print(sen)
12th May 2021, 1:37 AM
Semil P
0
num = int(input()) nums = list(x for x in range(1, num+1)) print(sum(nums))
28th Jul 2021, 11:42 PM
Diogo Gomes
Diogo Gomes - avatar
0
N = int(input()) #your code goes here print(N*(N+1)//2)
31st Jul 2021, 2:53 PM
David labadze
David labadze - avatar
0
sum = 0 for num in range(100): sum += num+1 print(sum)
1st Aug 2021, 7:56 PM
Bassel Omar Barji
0
# You are given N = int(input()) #your code goes here Total = 0 for x in range(1,N+1) Total+=x print(Total)
3rd Aug 2021, 6:24 PM
Aldrick KALISA MPANO
Aldrick KALISA MPANO - avatar
0
#your code goes here
9th Aug 2021, 7:04 AM
Phubej Asawatanawat
Phubej Asawatanawat - avatar