Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions ARKA.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
def sumOfSeries(n):
x = n * (n + 1) / 2
return (int)(x * x)
x = n * (n + 1) // 2 #// and return x * x: Keeps the calculation in exact integers with zero precision loss
return (x * x)


# Driver Function
n = 5
n = int(input("Enter a number: "))
print(sumOfSeries(n))


#SOURCE
'''
THIS CODE IS TO FIND SUM OF CUBES OF FIRST n NATURAL NUMBERS. Formula:

∑ k³ = [ n(n + 1) / 2 ]² (for k = 1 to n)
ex:
1³ + 2³ + ... + n³ = (n(n + 1) / 2)²

'''