Updating project euler #48. More functional