Groovy version of euler1