def func(n):
x = lambda a, b: sum(range(a, b, a))
return x(3, n) + x(5, n) - x(15, n) - x(9, n)
print(list(map(func, [1, 10, 100, 1000, 300000])))
ZGVmIGZ1bmMobik6CiAgICB4ID0gbGFtYmRhIGEsIGI6IHN1bShyYW5nZShhLCBiLCBhKSkKICAgIHJldHVybiB4KDMsIG4pICsgeCg1LCBuKSAtIHgoMTUsIG4pIC0geCg5LCBuKQoKCnByaW50KGxpc3QobWFwKGZ1bmMsIFsxLCAxMCwgMTAwLCAxMDAwLCAzMDAwMDBdKSkpCgo=