Solution to Project Euler Problem 433

I have this solution to the problem but it is very inefficient. I need help to make it better.