pure ruby implementation of prime.