Created
September 1, 2018 19:49
-
-
Save kthallam/0de69566c20238db16a80a597ab8d9ac to your computer and use it in GitHub Desktop.
Prime Number Program in Ruby
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
def primenumber(x) | |
temp = true | |
for i in 2..x/2 | |
if x%i == 0 | |
temp = false | |
break | |
end | |
end | |
if temp == true | |
puts "#{x} is a Prime Number" | |
else | |
puts "#{x} is a Composite Number" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment