Support Forums
isprime function - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Ruby and Ruby on Rails (https://www.supportforums.net/forumdisplay.php?fid=55)
+---- Thread: isprime function (/showthread.php?tid=5385)



isprime function - nevets04 - 03-24-2010

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



RE: isprime function - Arеs - 11-01-2010

Sorry for bumping this, but thanks!