Skip to content

Instantly share code, notes, and snippets.

@sghael
Forked from anonymous/it.rb
Last active August 29, 2015 13:56
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 sghael/9329023 to your computer and use it in GitHub Desktop.
Save sghael/9329023 to your computer and use it in GitHub Desktop.
def it(n)
x = [*2..n]
x.each do |i|
[*(i+1)..n].each { |j| x.delete(j) if (j%i).zero? }
end
end
# 1) what does it do?
# 2) how fast is it?
# 3) can you make it faster?
#
# Email answers to jobs@localytics.com with subject "Localytics Coding Challenge"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment