Skip to content

Instantly share code, notes, and snippets.

@river24
Created May 9, 2014 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save river24/9204f176cda4a250daf9 to your computer and use it in GitHub Desktop.
Save river24/9204f176cda4a250daf9 to your computer and use it in GitHub Desktop.
510から531までの素数を調べる
require 'prime'
range = 510..531
range.each do |num|
if Prime.instance.prime?(num)
print "#{num} is a prime : "
else
print "#{num} is not a prime : "
end
factors = num.prime_division
p factors
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment