Question two of project euler solved