Skip to content

Instantly share code, notes, and snippets.

@mantisbayne
Last active December 29, 2015 14:39
Show Gist options
  • Save mantisbayne/7685562 to your computer and use it in GitHub Desktop.
Save mantisbayne/7685562 to your computer and use it in GitHub Desktop.
def first_n_primes(n)
return "n must be an integer." unless n.is_a? Integer
return "n must be greater than 0." if n <= 0
prime_array = []
prime = Prime.new
for num in (1..n)
prime_array.push(prime.next)
end
prime_array
end
first_n_primes(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment