Skip to content

Commit 7e51932

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

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

maths/sum_of_squares.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
"""
2-
This script demonstrates the implementation of the sum of squares of the first n natural numbers.
2+
This script demonstrates the implementation of the
3+
sum of squares of the first n natural numbers.
34
45
The function takes an integer n as input and returns the sum of squares
5-
from 1 to n using the formula n(n + 1)(2n + 1) / 6. This formula computes the sum efficiently
6+
from 1 to n using the formula n(n + 1)(2n + 1) / 6.
7+
8+
This formula computes the sum efficiently
69
without the need for iteration.
710
811
https://www.cuemath.com/algebra/sum-of-squares/
@@ -11,7 +14,7 @@
1114

1215
def sum_of_squares(n: int) -> int:
1316
"""
14-
Implements the sum of squares formula for the first n natural numbers.
17+
Implements the sum of squares formulafor the first n natural numbers.
1518
1619
Parameters:
1720
n (int): A positive integer representing the limit of the series

0 commit comments

Comments
 (0)