Solved problem 41 in scala with brute force but fast algorithm