Problem 1 in Project Euler with a twist