Solution for euler problems in scala