Alex
0
Q:

python algorithm that takes a list of numbers and calculates the sum of the square of each number

# Python3 Program to 
# find sum of square  
# of first n natural  
# numbers 
  
# Return the sum of  
# square of first n 
# natural numbers 
def squaresum(n) : 
    return (n * (n + 1) * (2 * n + 1)) // 6
  
# Driven Program 
n = 4
print(squaresum(n)) 
  
#This code is contributed by Nikita Tiwari.                                                                
0
Input : N = 4
Output : 30
12 + 22 + 32 + 42
= 1 + 4 + 9 + 16
= 30

Input : N = 5
Output : 55
0

New to Communities?

Join the community