+2  A: 

The only way your script can fill up your disk is if it creates large/many temporary files and doesn't clean up. Just running a Python program cannot itself fill up your disk.

To recover the disk space, you need to figure out where the space is spent and remove the temporary files. Not sure how to do that on OSX, though. On Windows and Linux there are several excellent tools for visualizing disk usage.

EDIT: Euler-problems are designed to be solved in under a minute, even on modestly powerful computers. If you're spending 5 minutes, you're approaching the problem the wrong way.

JesperE
A: 

What I first though was that your program used a lot of memory which caused the swap file to grow. However, from the code I can see that it does not consume much memory. Therefore this script is not the cause of the lost space.

Roman Plášil
A: 

That's not python, that's something else on your system using memory... probably your browser.

1GB is not nearly enough free space on a Mac... you need at least 10GB free, so it's time to clean up.

Andrew McGregor