You can download this code by clicking the button below.
This code is now available for download.
This function calculates the sum of all numbers between start and end (inclusive) that are divisible by multiple.
Technology Stack : range, sum, if expression
Code Type : Mathematical calculation function
Code Difficulty :
def sum_of_multiples(start, end, multiple):
"""
计算在指定范围内的所有给定倍数的和。
"""
return sum(i for i in range(start, end + 1) if i % multiple == 0)