Created
June 15, 2012 07:54
-
-
Save fukayatsu/2935283 to your computer and use it in GitHub Desktop.
prime orz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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