next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: isPrime

isPrime -- whether a integer, polynomial, or ideal is prime

Synopsis

Description

i1 : ZZ/2[t];
i2 : isPrime(t^2+t+1)

o2 = true
i3 : isPrime(t^2+1)

o3 = false
i4 : isPrime 101

o4 = true
i5 : isPrime 158174196546819165468118574681196546811856748118567481185669501856749

o5 = true
i6 : isPrime 158174196546819165468118574681196546811856748118567481185669501856749^2

o6 = false

Since factor returns factors guaranteed only to be pseudoprimes, it may be useful to check their primality, as follows.

i7 : f = factor 28752093487520394720397634653456

      4
o7 = 2 109*1831*3014311519*2987077659845341

o7 : Expression of class Product
i8 : peek'_2 f

o8 = Product{Power{2, 4}, Power{109, 1}, Power{1831, 1}, Power{3014311519,
     ------------------------------------------------------------------------
     1}, Power{2987077659845341, 1}}
i9 : first \ toList f

o9 = {2, 109, 1831, 3014311519, 2987077659845341}

o9 : List
i10 : isPrime \ oo

o10 = {true, true, true, true, true}

o10 : List
This function can be used also to determine whether an ideal in a polynomial ring is prime.
i11 : R = QQ[a..d];
i12 : I = monomialCurveIdeal(R,{1,5,8})

                2    2      3    2 2   3     3    5        3   5    4
o12 = ideal (a*c  - b d, b*c  - a d , b c - a d, c  - a*b*d , b  - a c)

o12 : Ideal of R
i13 : isPrime I

o13 = true

Primality testing for integers is handled by pari.

See also

Ways to use isPrime :