On Thu, 20 Sep 2012, Stephen Pollei wrote: > If it says it might be prime it's > about a 50% 50% split if it's correct.
According to Wolfram, it's 75/25; so a positive result after 10 iterations leaves about a one-in-a-million chance of being composite (more precisely, one in 1048576). > multi method is-prime ( Int $x: Int $tries = 100) is export > should also at least document that tries is never a negative number, > or if it is that it has same behaviour as zero. Logically if "tries" is zero, is-prime shouldn't do any testing at all, and should always return "true". (There's a chance it might be prime!) If "tries" is negative, which idiom should we follow: * a range iterator (empty, zero tries, return true) * arrays etc count-backwards-from-the-end (keep trying until certain) * a logical ambiguity (return Any(true,false)) * you-get-what-you-ask-for (return "PEBKAC":but(false) ) * a logical contradiction (return an unthrown exception) * a formal error (throw an exception) -Martin