programming-examples/python/Function/Python program to calculate the sum of the positive integers.py
2019-11-15 12:59:38 +01:00

10 lines
254 B
Python

# Python program to calculate the sum of the positive integers of n+(n-2)+(n-4)... (until n-x =< 0)
def sum_series(n):
if n < 1:
return 0
else:
return n + sum_series(n - 2)
print(sum_series(6))
print(sum_series(10))