Skip to content

Commit 480338a

Browse files
committed
Create sum_ofsqauresof_nnaturalnumbers.py
This helps finding the sum of squares of first n natural numbers
1 parent 84e9378 commit 480338a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class squares_natural_numbers:
2+
def __init__(self, n):
3+
self.n = n
4+
5+
def get(self):
6+
a = (self.n * (self.n + 1) * (2 * self.n + 1)) / 6
7+
print("The sum of the squares of the first", self.n, "natural numbers is", a)
8+
9+
sol = squares_natural_numbers(2)
10+
sol.get()
11+

0 commit comments

Comments
 (0)