Advertisement
immanual1

2i

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