A one-liner.
>>> sum([i for i in range(10) if not (i%3 and i%5)])
23
>>> sum([i for i in range(1000) if not (i%3 and i%5)])
233168
So it's surprisingly interesting:
>>> for n in range(1,9):
... print sum([i for i in range(10**n) if not (i%3 and i%5)])
...
23
2318
233168
23331668
2333316668
233333166668
23333331666668
2333333316666668
Can't even come up with a succinct notation for the theorem, never mind any idea how to prove it.
No comments:
Post a Comment