Skip to content

Instantly share code, notes, and snippets.

@sanemat
Forked from anonymous/gist:4713925
Last active December 12, 2015 04:28
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 sanemat/4714203 to your computer and use it in GitHub Desktop.
Save sanemat/4714203 to your computer and use it in GitHub Desktop.
def prime?(number)
return false if number == 1
2.upto(number) do |key|
return false if number != key && number.to_f % key == 0
end
true
end
primes = [*1...100].select{|n| prime? n}
data = []
primes.each do |m|
primes.each do |n|
next if m * n > 100
data << m * n
end
end
data.sort.uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment