Skip to content

Instantly share code, notes, and snippets.

@charlesponti
Created May 6, 2013 18:08
Show Gist options
  • Save charlesponti/5526905 to your computer and use it in GitHub Desktop.
Save charlesponti/5526905 to your computer and use it in GitHub Desktop.
Project Euler: Problem 7
def is_prime?(num)
2.upto(num-1) { |i| return false if ((num % i) == 0) }
true
end
def this_prime(position)
results = []
i = 2
until results.count == position
results << i if is_prime?(i)
i += 1
end
p results.last
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment