Dont uderstand this?

this little snippet of code is hard for me to decipher,

def prime_factors(n)
return [] if n == 1
factor = (2..n).find {|x| n % x == 0}
[factor] + prime_factors(n / factor)
puts prime_factors(600851475143).max

Can you explain it?
why do we return a blank array if n == 1?>

Because it is a recursive function, i.e. a function which calls itself.
n==1 is a “break condition” which serves to stop the function calling itself for ever (or until the stack size is exceeded).