def sum_multiples_of(a, b, n):
    """Get the sum of all multiples of A and B up to N."""
    total = 0
    for i in range(1, n):
        if not i % a or not i % b:
            total += i
    return total