Варіант перший:
infile = open('input.txt')
outfile = open('output.txt', 'w')
N = int(infile.readline())
s = 0
for x in range(0, N+1):
s += x
outfile.write(str(s))
infile.close()
outfile.close()
Варіант другий:
infile = open('input.txt')
outfile = open('output.txt', 'w')
N = int(infile.readline())
s = 0
while N > 0:
s += N
N -= 1
outfile.write(str(s))
infile.close()
outfile.close()
Немає коментарів:
Дописати коментар