Last active
August 29, 2015 14:04
-
-
Save mcihad/40c916903200a197d75b to your computer and use it in GitHub Desktop.
Ruby asal sayı
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
#require "prime" diyerek standart prime modulünüde kullanabilirsiniz | |
class Fixnum | |
def prime? | |
2.upto((self-(self % 2))/2) do |i| | |
if self % i==0 | |
return false | |
end | |
end | |
return true | |
end | |
end | |
puts 12.prime? | |
puts 99991.prime? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment