面试题答案
一键面试nums = [1, 4, 9, 16, 25]
def square_index_sum(n):
total = 0
length = len(nums)
end = n if n <= length else length
for i in range(end):
total += i * nums[i]
return total
nums = [1, 4, 9, 16, 25]
def square_index_sum(n):
total = 0
length = len(nums)
end = n if n <= length else length
for i in range(end):
total += i * nums[i]
return total