greatly simplified prime generation

or anyway, made it more readable