{"id":22650,"date":"2021-09-27T09:20:59","date_gmt":"2021-09-27T03:50:59","guid":{"rendered":"https:\/\/python-programs.com\/?p=22650"},"modified":"2021-11-22T18:35:38","modified_gmt":"2021-11-22T13:05:38","slug":"python-program-to-find-sum-of-series-1-22-33-5-n-n1","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-sum-of-series-1-22-33-5-n-n1\/","title":{"rendered":"Python Program to Find Sum of Series 1\/2!+2\/3!+3\/5!+…..N\/(N+1)!"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Find Sum of Series 5^2+10^2+15^2+…..N^2<\/a> Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to find the sum of series (1\/2!+2\/3!+3\/5!+…..N\/(N+1)!)<\/strong> till the given number N in Python:<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n If you are learning Python then the Python Programming Example<\/a> is for you and gives you a thorough description of concepts for beginners, experienced programmers.<\/p>\n In the previous article, we have discussed Python Program to Find Sum of Series 5^2+10^2+15^2+…..N^2 Given a number N and the task is to find the sum of series (1\/2!+2\/3!+3\/5!+…..N\/(N+1)!) till the given number N in Python. Examples: Example1: Input: Given Number (Limit) = 6 Output: The above series sum till the given number N{ …<\/p>\n
\nGiven a number N and the task is to find the sum of series (1\/2!+2\/3!+3\/5!+…..N\/(N+1)!)<\/strong> till the given number N in Python.<\/p>\nGiven Number (Limit) = 6<\/pre>\n
The above series sum till the given number N{ 6 } = 0.9998015873015872<\/pre>\n
Given Number (Limit) = 13<\/pre>\n
The above series sum till the given number N{ 13 } = 0.9999999999885293<\/pre>\n
Program to Find Sum of Series 1\/2!+2\/3!+3\/5!+…..N\/(N+1)!<\/h2>\n
\n
Method #1: Using While Loop (Static Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the number N(limit) as static input and store it in a variable.\r\ngvn_numb = 6\r\n# Take a variable to say itr and initialize its value to 1.\r\nitr = 1\r\n# Take a variable to say rsltseries_summ and initialize its value to 0.0\r\n# (Floating point number)\r\nrsltseries_summ = 0.0\r\n# Loop until the above-declared variable itr value is less than or equal to the\r\n# given number using the while loop.\r\nwhile(itr <= gvn_numb):\r\n # Calculate the factorial of itr+1 using the math.factorial() method and\r\n # store it in another variable.\r\n factrl = math.factorial(itr+1)\r\n # Calculate the value of itr divided by the above result factorial and convert it\r\n # into float using the float() function.\r\n # Store it in another variable.\r\n p = float(itr\/factrl)\r\n # Add the above result to the\u00a0rsltseries_summ and store it in the same variable.\r\n rsltseries_summ += p\r\n # Increment the above itr value by 1.\r\n itr += 1\r\n# Print the sum of series till the given number N.\r\nprint(\r\n \"The above series sum till the given number N{\", gvn_numb, \"} = \", rsltseries_summ)\r\n<\/pre>\n
The above series sum till the given number N{ 6 } = 0.9998015873015872<\/pre>\n
Method #2: Using While loop (User Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the number N (Limit) as user input using the int(input()) function and \r\n# store it in a variable.\r\ngvn_numb = int(input(\"Enter some Random Number = \"))\r\n# Take a variable to say itr and initialize its value to 1.\r\nitr = 1\r\n# Take a variable to say rsltseries_summ and initialize its value to 0.0\r\n# (Floating point number)\r\nrsltseries_summ = 0.0\r\n# Loop until the above-declared variable itr value is less than or equal to the\r\n# given number using the while loop.\r\nwhile(itr <= gvn_numb):\r\n # Calculate the factorial of itr+1 using the math.factorial() method and\r\n # store it in another variable.\r\n factrl = math.factorial(itr+1)\r\n # Calculate the value of itr divided by the above result factorial and convert it\r\n # into float using the float() function.\r\n # Store it in another variable.\r\n p = float(itr\/factrl)\r\n # Add the above result to the\u00a0rsltseries_summ and store it in the same variable.\r\n rsltseries_summ += p\r\n # Increment the above itr value by 1.\r\n itr += 1\r\n# Print the sum of series till the given number N.\r\nprint(\r\n \"The above series sum till the given number N{\", gvn_numb, \"} = \", rsltseries_summ)\r\n\r\n<\/pre>\n
Enter some Random Number = 13\r\nThe above series sum till the given number N{ 13 } = 0.9999999999885293<\/pre>\n
\n