Hi I find that I not understand all of the code provided there, can anybody explain it?

def prime(n)

puts "That's not an integer." unless n.is_a? Integer

is_prime = true

for i in 2..n-1

if n % i == 0

is_prime = false

end

end

if is_prime

puts "#{n} is prime!"

else

puts "#{n} is not prime."

end

end

Especially I confused with this line: " for i in 2..n-1" what it does?

I find out that output will be the same if change that line to : "for i in 2...n"

So it's mean we don't need to divide by number itself because result obviously will be 1

And on line below we dividing all others numbers and see if result contains any remainder