Returning the sum of all multiples of a number up to 1000 I've been learning Python and in order to put my skills to the test, I created a simple program that returns the sum of all of the multiples of number num up to 1000.

def get_multiple_sum(num):
    sum = 0
    i = 0
    for i in range(0, 1001):
        if i % num == 0:
            sum += i
        else:
            continue
    return sum


Is this the fastest way to do this? I'm always looking for ways to make my code more efficient.
range takes an optional third argument, which is the step size for the sequence. For example:

range(0, 10, 3) # Returns [0, 3, 6, 9]


Python also has a built-in sum function that adds up all the numbers in an array, so you could refactor your code to look like this:

def get_multiple_sum(num):
    return sum(range(0, 1000, num))


Performance-wise, this should be much faster, as it doesn't perform 1000 remainder operations and uses a library function which may be optimized by the interpreter.