I was traying to write a code that calculate the sum of 2*j+i+1 where 0<=j<=i<=n but I wasn't very optimazed there are my code :
def get_sum(n):
s=0
for j in range(n+1):
ss=0
ss=sum(2*j+i+1 for i in range(j,n+1))
s+=ss
return s
Write to calculate a a sum of 2*j+i+1 where 0<=j<=i<=n but it wasn't optimazed
source https://stackoverflow.com/questions/74267736/i-need-to-optimaze-my-code-that-containt-two-loops-the-code-is-for-calculating
Comments
Post a Comment