Working on “loop”.

I can’t get the following simple loop to work. What am I doing wrong?

puts “Enter a number or ‘q’ to terminate”

loop do

n = gets.chomp

if (n == ‘q’) then

break

else

is_prime = true

for i in 2…n-1

if n % i == 0

is_prime = false

end

end

if is_prime

puts “#{n} is a prime.”

else

puts “#{n} is not a prime.”

end

end

end

Thanks in advance.