# Write this function
![](http://i.imgur.com/mlbRlEm.png)
`for i from 1 to n`, do `i % m` and return the `sum`
    f(n=10, m=5) // returns 20 (1+2+3+4+0 + 1+2+3+4+0)
*You'll need to get a little clever with performance, since n can be a very large number*
def f(n, m):
    times = n // m
    extra = n % m
    sum_mini_series = (m - 1) * (m - 1 + 1) // 2
    sum_extra = (extra) * (extra + 1) // 2
    return sum_mini_series * times + sum_extra
def f(n, m):
    times = n // m
    extra = n % m
    sum_mini_series = (m - 1) * (m - 1 + 1) // 2
    sum_extra = (extra) * (extra + 1) // 2
    return sum_mini_series * times + sum_extra