Question: Sum of Squares Write a function sum _ squares ( n ) that returns the sum of the perfect squares 1 2 + 2 2

Sum of Squares
Write a function sum_squares (n) that returns the sum of the perfect squares 12+22+cdots+n2 using the formula
S=n(n+1)(2n+1)6
Assume that n is a positive integer. The return value should be an int .(Note that the formula always evaluates to an integer. Why is that?)
Example:
sum_squares(200) returns 2686700(not 2686700.0).
 Sum of Squares Write a function sum_squares (n) that returns the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!