CoCoA:IsPrime

From ApCoCoAWiki

IsPrime

prime integer test

Description

This function determines whether a small integer is prime.

The range of permitted values for N is the same the range

of permitted values for the NextPrime function: on most platforms <formula>N <less_eq/> 45000</formula> should work fine, on some platforms considerably larger values will work. For N greater than the limit an error is raised.

Example

  IsPrime(32003);
TRUE
-------------------------------
  IsPrime(10^100);
ERROR: IsPrime: number too large
CONTEXT: Return(Error(<quotes>IsPrime: number too large</quotes>))
-------------------------------

Syntax

IsPrime(N:INT):BOOL

IsPPrime

NextPrime

   <type>integer</type>
   <type>boolean</type>