Question: I'm trying the list all factors of a number using the following method:

```
def find_factors(n)
  factors = []
  2.upto(n-1) {|x| factors << x if n % x == 0}
end

factor = find_factors(24)
puts factor

```

Its printing out the following:

```
2

```

instead of the list of factors! What am if doing incorrectly?

Answer: 
In ruby, whenever you see an array initialization before a loop, you can generally convert it to a more functional approach:

```
def find_factors(n)
  2.upto(n-1).select{|x| n % x == 0}
end

```

This tends to be more compact and often more readable too.
You have to return `factors` at the end of your `find_factors` method:

```
def find_factors(n)
  factors = []
  2.upto(n-1) {|x| factors << x if n % x == 0}
  factors
end

```