Solution of Euler Problem 54 with scala