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


Messages In This Thread
isprime function - by nevets04 - 03-24-2010, 08:47 PM
RE: isprime function - by Arеs - 11-01-2010, 09:12 AM

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

Forum Jump:


Users browsing this thread: 1 Guest(s)