0
What's the mistake with this code?
This code give the sum of N numbers N = int(input()) #your code goes here Z=range (N) x=0 for i in Z : x=x+i print (x)
4 odpowiedzi
+ 5
Z=range (N+1)
+ 1
It should be something lile this:
N = int(input())
x = 0
for i in range(N+1):
x += i
print(x)
+ 1
Thanks all🥰
0
n = int(input())
Mathematical Solution
Ans= n*(n+1)/2
Brute forcing
Ans = sum(range(n+1))