Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Created June 15, 2012 07:54
Show Gist options
  • Save fukayatsu/2935283 to your computer and use it in GitHub Desktop.
Save fukayatsu/2935283 to your computer and use it in GitHub Desktop.
prime orz
#!/usr/bin/env ruby
@INPUT = ARGV[0].to_i
if @INPUT == nil then
puts '[usage] ex) ruby prime.rb 5'
exit
end
(2..Math.sqrt(@INPUT)).each do |i|
if @INPUT % i == 0 then
puts 'false'
exit 0
end
end
puts 'true'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment