Chalarangelo/30-seconds-of-python

Improving `sum_of_powers` snippet

gurukiran07 opened this issue · 2 comments

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.

Sure, you can go ahead and PR this. Also, please add Resolves #354 in the PR to auto-close the issue when merged.

@Trinityyi Submitted a PR #357 .