Improving `sum_of_powers` snippet
gurukiran07 opened this issue · 2 comments
gurukiran07 commented
Current implementation
def sum_of_powers(end, power = 2, start = 1):
return sum([(start + i) ** power for i in range(0, end + 1 - start)])
Can be refactored into
def sum_of_powers(end, power = 2, start = 1):
return sum([(i) ** power for i in range(start, end + 1)])
Produces the same results.
Trinityyi commented
Sure, you can go ahead and PR this. Also, please add Resolves #354
in the PR to auto-close the issue when merged.
gurukiran07 commented
@Trinityyi Submitted a PR #357 .