A Simple Primality Test and th rth Smallest Prime Factor