03-24-2010, 08:47 PM
Code:
def isprime(a)
array = []
if a > 9
for x in 2..9 do
if a % x == 0
array << "Not Prime"
else
array << "Primne"
end
end
end
if a <= 9
if a == 1 or a == 2 or a == 3 or a == 5 or a == 7
array << "Prime"
end
if a == 4 or a == 6 or a == 8 or a == 9
array << "Not Prime"
end
end
if array.include?("Not Prime")
puts "Not Prime"
else
puts "Prime"
end
end