Skip to content

Instantly share code, notes, and snippets.

@0xeuclid
Created August 29, 2012 16:05
Show Gist options
  • Save 0xeuclid/3514907 to your computer and use it in GitHub Desktop.
Save 0xeuclid/3514907 to your computer and use it in GitHub Desktop.
Find prime numbers
=begin
If you want to find prime numbers less than N
then use each prime number form 2 to N**0.5 to test.
=end
print "2, 3, 5, 7, "
for i in (10..100)
if (i%2 != 0 and i%3 != 0 and i%5!=0 and i%7!=0)
print "#{i}, "
end
end
puts
# Output:
# 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment