fork download
  1. #!/usr/local/bin/ruby -w
  2.  
  3. class Integer
  4. def prime?
  5. (2..(Math.sqrt(abs).ceil)).none?{|n|abs % n == 0}
  6. end
  7. end
  8.  
  9. p((10..50).select(&:prime?))
  10. p((-50..-10).select(&:prime?))
Success #stdin #stdout 0s 4760KB
stdin
Standard input is empty
stdout
[11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
[-47, -43, -41, -37, -31, -29, -23, -19, -17, -13, -11]