Task

Write a program to find the sum of squares of a numeric vector.

The program should work on a zero-length vector (with an answer of   0).



Related task

   Mean


 
Function sum_of_squares(arr)
	If UBound(arr) = -1 Then
		sum_of_squares = 0
	End If
	For i = 0 To UBound(arr)
		sum_of_squares = sum_of_squares + (arr(i)^2)
	Next
End Function
 
WScript.StdOut.WriteLine sum_of_squares(Array(1,2,3,4,5))
WScript.StdOut.WriteLine sum_of_squares(Array())
 