Previous Page Next Page Contents

isprime -- primality test

Introduction

isprime(n) checks whether n is a prime number.

Call(s)

isprime(n)

Parameters

n - an arithmetical expression representing an integer

Returns

either TRUE or FALSE, or a symbolic isprime call.

Related Functions

factor, ifactor, igcd, ilcm, irreducible, ithprime, nextprime, numlib::primedivisors, numlib::prevprime, numlib::proveprime

Details

Example 1

The number 989999 is prime:

>> isprime(989999)
                                   TRUE
>> ifactor(989999)
                                  989999

In contrast to ifactor, isprime can handle large numbers:

>> isprime(2^(2^11) + 1)
                                   FALSE

isprime(0) and isprime(1) return FALSE:

>> isprime(0), isprime(1)
                               FALSE, FALSE

Negative numbers yield FALSE as well:

>> isprime(-13)
                                   FALSE

For non-numeric arguments, a symbolic isprime call is returned:

>> delete n: isprime(n)
                                isprime(n)

Background

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000