loading
open in
main.py
1
2
3
4
5
6
7
8
9
def sumn(n, d): #sum numbers <= n that are divisible by d
    n //= d
    return d*n*(n+1) // 2

L = int(input('Enter a limit?'))
a, b = 3, 5

s = sumn(L-1, a) + sumn(L-1, b) - sumn(L-1, a*b)
print "Sum of multiples of",a,"or",b,"below", L, "=", s
Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux