Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum_of_mixed_series(n):
- # This series alternates between adding 1 and adding 2
- sum = 0
- for i in range(1, n + 1):
- if i % 2 == 0:
- sum += i - 1
- else:
- sum += i
- return sum
- n = int(input("Enter the value of N: "))
- sum = sum_of_mixed_series(n)
- print("Sum of the series:", sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement