Skip to content

Instantly share code, notes, and snippets.

@kthallam
Created September 1, 2018 19:49
Show Gist options
  • Save kthallam/0de69566c20238db16a80a597ab8d9ac to your computer and use it in GitHub Desktop.
Save kthallam/0de69566c20238db16a80a597ab8d9ac to your computer and use it in GitHub Desktop.
Prime Number Program in Ruby
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