Project Euler done in (mostly) functional Python