{"id":22648,"date":"2021-09-27T08:35:20","date_gmt":"2021-09-27T03:05:20","guid":{"rendered":"https:\/\/python-programs.com\/?p=22648"},"modified":"2021-11-22T18:35:39","modified_gmt":"2021-11-22T13:05:39","slug":"python-program-to-find-sum-of-series-5-2-10-2-15-2-n-2","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-sum-of-series-5-2-10-2-15-2-n-2\/","title":{"rendered":"Python Program to Find Sum of Series 5^2 + 10^2 + 15^2 +…..N^2"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Print Series 0 2 6 12 20 30 42…N<\/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 (5^2+10^2+15^2+…..N^2)<\/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 Grab the opportunity and utilize the Python Program Code Examples<\/a> over here to prepare basic and advanced topics too with ease and clear all your doubts.<\/p>\n In the previous article, we have discussed Python Program to Print Series 0 2 6 12 20 30 42…N Given a number N and the task is to find the sum of series (5^2+10^2+15^2+…..N^2) till the given number N in Python. Examples: Example1: Input: Given Number (Limit) = 25 Output: The above given series sum …<\/p>\n
\nGiven a number N and the task is to find the sum of series (5^2+10^2+15^2+…..N^2)<\/strong> till the given number N in Python.<\/p>\nGiven Number (Limit) = 25<\/pre>\n
The above given series sum = 1375<\/pre>\n
Given Number (Limit) = 14<\/pre>\n
The above given series sum = 125<\/pre>\n
Program to Find Sum of Series 5^2+10^2+15^2+…..N^2 in Python<\/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 = 25\r\n# Take a variable to say itr and initialize its value to 5.\r\nitr = 5\r\n# Take a variable to say rsltseries_summ and initialize its value to 0.\r\nrsltseries_summ = 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 value of itr raised to the power 2 (square) using the pow() function\r\n # and store it in another variable.\r\n k = pow(itr, 2)\r\n # Add the above result to the rsltseries_summ and store it in the\r\n # same variable.\r\n rsltseries_summ += k\r\n # Increment the above itr value by 5.\r\n itr += 5\r\nprint(\"The above given series sum = \", rsltseries_summ)\r\n<\/pre>\n
The above given series sum = 1375<\/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 5.\r\nitr = 5\r\n# Take a variable to say rsltseries_summ and initialize its value to 0.\r\nrsltseries_summ = 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 value of itr raised to the power 2 (square) using the pow() function\r\n # and store it in another variable.\r\n k = pow(itr, 2)\r\n # Add the above result to the rsltseries_summ and store it in the\r\n # same variable.\r\n rsltseries_summ += k\r\n # Increment the above itr value by 5.\r\n itr += 5\r\nprint(\"The above given series sum = \", rsltseries_summ)\r\n\r\n<\/pre>\n
Enter some Random Number = 14\r\nThe above given series sum = 125<\/pre>\n
\n