From P. Euler, done in C++, Python, and Java