Ruby version of prime.