我正在尝试查看用户是否输入了质数。我希望它在屏幕上打印“PRIME”或“NOT PRIME”:
prime = ""
puts "TYPE IN A NUMBER TO SEE IF IT'S PRIME: "
gets.chomp(prime).to_i
for divide_by in 2..(prime.to_i - 1)
if prime % divide_by == 0
puts "NOT PRIME!!!"
else
puts "PRIME!!!"
end
end
我应该使用while
循环吗?