isprime(::BigInt, ?)

isprime(x::BigInt, [reps = 25]) -> Bool

Probabilistic primality test. Returns true if x is prime; and false if x is not prime with high probability. The false positive rate is about 0.25^reps. reps = 25 is considered safe for cryptographic applications (Knuth, Seminumerical Algorithms).

julia> isprime(big(3))


The isprime(::Integer) function in Julia determines whether a given integer x is prime or not. It returns true if x is prime and false otherwise.

julia> isprime(3)

Here are some common examples of using the isprime function:

  1. Check if a number is prime:

    julia> isprime(7)
  2. Verify if a large number is prime:

    julia> isprime(10^9 + 7)
  3. Identify non-prime numbers:

    julia> isprime(10)
  4. Use the function in a conditional statement:
    julia> num = 13;
    julia> if isprime(num)
              println("$num is prime")
              println("$num is not prime")

Please note that the isprime function works only with integers. If a non-integer value is passed, an error will occur.

See Also

digits, inf, isdigit, iseven, isfinite, isless, islower, isnumber, isodd, isprime, isqrt, issorted, issubnormal, isxdigit, nan,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: