Sometimes it’s useful to have a simpe program around to answer if a certain number is a prime number or not. With a few lines of Python this is easy to build. The following small program prompts for a number and answer if it’s a prime or not. You can also read the exit code of the program in case you want to implement it in another program or a shell script. The program will quit with exit code 0 if it’a prime number, and 1 if it’s not. This program only works for numbers greater than 1, since it starts checking by dividing by 2. I think this is okay, since we all know (or nowdays consider) 1 to be the first prime number.
Update 2021-02-15: Life has come along way since I wrote this article, even though it’s only five years ago. Today I use Docker every day, both personally and professionally. Nowadays I see the benefits of Docker and have learned a great deal since I wrote this. It’s interesting to look back on your own thoughts and see how much you (and the world) has changed. Therefore, I have kept the rest of this article intact.