Skip to content

Commit 2dfeac1

Browse files
authored
Update sum_of_squares.py
1 parent 7e51932 commit 2dfeac1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

maths/sum_of_squares.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
"""
1313

1414

15-
def sum_of_squares(n: int) -> int:
15+
def sum_of_squares(num_of_terms: int) -> int:
1616
"""
1717
Implements the sum of squares formulafor the first n natural numbers.
1818
1919
Parameters:
20-
n (int): A positive integer representing the limit of the series
20+
num_of_terms (int): A positive integer representing the limit of the series
2121
2222
Returns:
2323
sum_squares (int): The sum of squares of the first n natural numbers.
@@ -29,7 +29,7 @@ def sum_of_squares(n: int) -> int:
2929
>>> sum_of_squares(10)
3030
385
3131
"""
32-
return n * (n + 1) * (2 * n + 1) // 6
32+
return num_of_terms * (num_of_terms + 1) * (2 * num_of_terms + 1) // 6
3333

3434

3535
if __name__ == "__main__":

0 commit comments

Comments
 (0)