Inelegant solution for Euler123.