isPrime(rounds:)

Returns true if this integer is probably prime. Returns false if this integer is definitely not prime.

Prime Test.swift:149
func isPrime(rounds: Int = 10) -> Bool

This function performs a probabilistic Miller-Rabin Primality Test, consisting of rounds iterations, each calculating the strong probable prime test for a random base. The number of rounds is 10 by default, but you may specify your own choice.

To speed things up, the function checks if self is divisible by the first few prime numbers before diving into (slower) Miller-Rabin testing.

Also, when self is less than 82 bits wide, isPrime does a deterministic test that is guaranteed to return a correct result.