Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
isprime function
#1
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
Reply
#2
Sorry for bumping this, but thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  GCF Function nevets04 1 1,598 12-03-2011, 02:32 PM
Last Post: HF~Legend

Forum Jump:


Users browsing this thread: 1 Guest(s)