Refactored prime.rb