This is Rosetta Code's Python 3 algorithm for trial division.