Created
April 24, 2017 02:12
-
-
Save hyuki0000/8a84085715545078942163abf4d01aff to your computer and use it in GitHub Desktop.
円周率のような数字列を頭から見て素数を探す
This file contains 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 | |
require 'prime' | |
s = "31415926535" | |
s.length.times do |k| | |
t = s[0..k].to_i | |
if t.prime? | |
puts "#{t} is prime." | |
else | |
puts "#{t} is not prime." | |
end | |
end |
Author
hyuki0000
commented
Apr 24, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment