Optimize a function in Python that calculates the sum of numbers from 0 to n.
def slow_sum(n):
    s = 0
    for number in range(n+1):
        s += number
    return s
def fast_sum(n):
    return ((n+1)*n)/2