If we list all the natural numbers below $10$ that are multiples of $3$ or $5$, we get $3, 5, 6$ and $9$. The sum of these multiples is $23$.
Find the sum of all the multiples of $3$ or $5$ below infinity.
We won't need to write any code to solve this bonus problem. This is a twist on Problem 1 where we used a formula for the sum of multiples of $a$ or $b$ below $L$ using the inclusion-exclusion principle:
but now $L = \infty$ so how can we compute $s$?
The sum $1 + 2 + 3 + 4 + \cdots$ obviously diverges. However, using Ramanujan summation or zeta function regularization, we can assign it a finite value.
The Riemann zeta function is defined for $\operatorname{Re}(z) > 1$ as
and can be analytically continued to the entire complex plane (except for a pole at $z = 1$). Evaluating at $z = -1$ gives
You can think of this result as what happens when you "extrapolate" the value of $\zeta(z)$ to negative values of $z$.
Using this we can now compute the sum of all multiples of $3$ or $5$ below infinity:
Numberphile has a pretty good YouTube video on how $\zeta(-1) = -1/12$. Also, there's a pretty good 2015 film about Ramanujan, The Man Who Knew Infinity, based on a book of the same name.