 # Python Program to Find Sum of Series 5^2 + 10^2 + 15^2 +…..N^2

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 =  1375

Example2:

Input:

Given Number (Limit) = 14

Output:

The above given series sum =  125

## Program to Find Sum of Series 5^2+10^2+15^2+…..N^2 in Python

Below are the ways to find the sum of series (5^2+10^2+15^2+…..N^2) till the given number N in Python:

### Method #1: Using While Loop (Static Input)

Approach:

• Import math module using the import keyword.
• Give the number N (Limit) as static input and store it in a variable.
• Take a variable to say itr and initialize its value to 5.
• Take another variable to say rsltseries_summ and initialize its value to 0.
• Loop until the above-declared variable itr value is less than or equal to the given number using the while loop.
• Calculate the value of itr raised to the power 2 (square) using the pow() function and store it in another variable.
• Add the above result to the rsltseries_summ and store it in the same variable.
• Increment the above itr value by 5.
• Print the sum of series till the given number N.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the number N(limit) as static input and store it in a variable.
gvn_numb = 25
# Take a variable to say itr and initialize its value to 5.
itr = 5
# Take a variable to say rsltseries_summ and initialize its value to 0.
rsltseries_summ = 0
# Loop until the above-declared variable itr value is less than or equal to the
# given number using the while loop.
while(itr <= gvn_numb):
# Calculate the value of itr raised to the power 2 (square) using the pow() function
# and store it in another variable.
k = pow(itr, 2)
# Add the above result to the rsltseries_summ and store it in the
# same variable.
rsltseries_summ += k
# Increment the above itr value by 5.
itr += 5
print("The above given series sum = ", rsltseries_summ)


Output:

The above given series sum =  1375

### Method #2: Using While loop (User Input)

Approach:

• Import math module using the import keyword.
• Give the number N (Limit) as user input using the int(input()) function and store it in a variable.
• Take a variable to say itr and initialize its value to 5.
• Take another variable to say rsltseries_summ and initialize its value to 0.
• Loop until the above-declared variable itr value is less than or equal to the given number using the while loop.
• Calculate the value of itr raised to the power 2 (square) using the pow() function and store it in another variable.
• Add the above result to the rsltseries_summ and store it in the same variable.
• Increment the above itr value by 5.
• Print the sum of series till the given number N.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the number N (Limit) as user input using the int(input()) function and
# store it in a variable.
gvn_numb = int(input("Enter some Random Number = "))
# Take a variable to say itr and initialize its value to 5.
itr = 5
# Take a variable to say rsltseries_summ and initialize its value to 0.
rsltseries_summ = 0
# Loop until the above-declared variable itr value is less than or equal to the
# given number using the while loop.
while(itr <= gvn_numb):
# Calculate the value of itr raised to the power 2 (square) using the pow() function
# and store it in another variable.
k = pow(itr, 2)
# Add the above result to the rsltseries_summ and store it in the
# same variable.
rsltseries_summ += k
# Increment the above itr value by 5.
itr += 5
print("The above given series sum = ", rsltseries_summ)



Output:

Enter some Random Number = 14
The above given series sum = 125

Grab the opportunity and utilize the Python Program Code Examples over here to prepare basic and advanced topics too with ease and clear all your doubts.