EulerProblem4_opt  working fast and ugly

I got this approach to work, and it works fast.
I need to clean up the code, it is repetitive and unpleasant to read.