Before I started writing this myself, did anyone see a ruby implementation of the following behavior?
puts 7.nextprime(); #=> 11 puts 7.previousprime(); #=> 5 puts 7.isprime(); #=> true
Obviously, this kind of thing would be ugly for large numbers, but for integers not exceeding several thousand (a common example for me), a reasonable implementation is feasible, hence the question.
source share