Intern
Write a complete sum_series function in Python and test it with an example from the task.
sobes.tech AI
Answer from AI
def sum_series(n): """Calculates the sum of the first n terms of an arithmetic progression, for example, 1 + 2 + ... + n""" return n * (n + 1) // 2
Function check with example
print(sum_series(5)) # Expected result: 15 (1+2+3+4+5)