{"id":20072,"date":"2021-09-06T13:36:36","date_gmt":"2021-09-06T08:06:36","guid":{"rendered":"https:\/\/python-programs.com\/?p=20072"},"modified":"2021-11-22T18:36:27","modified_gmt":"2021-11-22T13:06:27","slug":"python-program-to-find-sum-of-series-1-2-3-4-5-n","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-sum-of-series-1-2-3-4-5-n\/","title":{"rendered":"Python Program to Find Sum of Series 1-2+3-4+5…+N"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Find Sum of Series 1+1\/3+1\/5+1\/7+…..1\/(N+2)<\/a><\/p>\n

Given a number N and the task is to find the sum of the given series (1-2+3-4+5…+N)<\/strong>\u00a0for the given number in Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 20<\/pre>\n

Output:<\/strong><\/p>\n

The total sum of the series till the given number { 20 } =  -10<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 7<\/pre>\n

Output:<\/strong><\/p>\n

The total sum of the series till the given number { 7 } =  4<\/pre>\n

Program to Find Sum of Series 1-2+3-4+5…+N in Python<\/h2>\n

Below are the ways to find the sum of the given series (1-2+3-4+5…+N)<\/strong> for the given number in Python:<\/p>\n