mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-22 13:47:37 +00:00
Update sum_of_squares.py
This commit is contained in:
parent
37c0953597
commit
78849a7437
@ -4,6 +4,8 @@ This script demonstrates the implementation of the sum of squares of the first n
|
||||
The function takes an integer n as input and returns the sum of squares
|
||||
from 1 to n using the formula n(n + 1)(2n + 1) / 6. This formula computes the sum efficiently
|
||||
without the need for iteration.
|
||||
|
||||
https://www.cuemath.com/algebra/sum-of-squares/
|
||||
"""
|
||||
|
||||
def sum_of_squares(n: int) -> int:
|
||||
|
Loading…
x
Reference in New Issue
Block a user