Create P37.py: Algorithm can be improved for quicker iteration