Project Euler challenge 1 in D