Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum_of_alternating_series(n):
- sum = 0
- for i in range(1, n + 1):
- sum += (-1) ** (i + 1) * i
- return sum
- n = int(input("Enter the value of N: "))
- sum = sum_of_alternating_series(n)
- print("Sum of the series:", sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement