def sumn(n, d): # Sum natural numbers ≤ n that are divisible by d n //= d return d*n*(n+1) // 2 L = int(input('Enter an upper bound? ')) 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)