Advertisement
immanual1

2e

Jan 13th, 2025
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. def sum_of_alternating_series(n):
  2. sum = 0
  3. for i in range(1, n + 1):
  4. sum += (-1) ** (i + 1) * i
  5. return sum
  6.  
  7. n = int(input("Enter the value of N: "))
  8. sum = sum_of_alternating_series(n)
  9. print("Sum of the series:", sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement