# Haven't quite been able to determine the solution

#1

I am having the same problem with this one (returns 1..10) and haven't quite been able to determine the solution:

\$VERBOSE = nil
require 'prime'

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``````

end

first_n_primes(10)

4 - Less is More
#2

Found a solution to this, albeit not the most elegant. Replaces the return statement instead of simply removing it, which defeats the purpose of using an implicit return:

``````\$VERBOSE = nil    # We'll explain this at the end of the lesson.
require 'prime'   # This is a module. We'll cover these soon!

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.push()
end

first_n_primes(10)``````

#3

This is not dynamic. It should correspond to the inputs.

``n.times do``

or

``for num in (1..n)``

There is no return value. add one last line to the method:

``````    prime_array
end``````

#4

I pasted the wrong solution. Edited above

#5

I understand your point - thanks for assistance.

#6