Tasks 6 and 7 of ProjectEuler.
Some changes made to other tasks in the form of commenting.