## `numlib::primroot` -- primitive roots

#### Introduction

`numlib::primroot``(m)` returns the least positive primitive root modulo `m` if there exist primitive roots modulo `m`.

`numlib::primroot``(a, m)` returns the least primitive root modulo `m` not smaller than `a` if there exist primitive roots modulo `m`.

#### Call(s)

`numlib::primroot(m)`
`numlib::primroot(a, m)`

#### Parameters

`a` | - | an integer
`m` | - | a natural number

#### Returns

`numlib::primroot` returns an integer or `FAIL`.

#### Related Functions

`numlib::order`

#### Details

- `numlib::primroot` returns `FAIL` if there exist no primitive roots modulo `m`.
- `numlib::primroot` returns the function call with evaluated argument(s) if at least one argument is not a number.
- `numlib::primroot` returns an error if the arguments evaluate to numbers which are not both of the correct type.

#### Example 1

We compute the least positive primitive root modulo the prime number 40487:

    >> numlib::primroot(40487)

                                         5

#### Example 2

We compute the least primitive root modulo 404872 = 1639197169:

    >> numlib::primroot(1639197169)

                                        10

#### Example 3

Now we compute least primitive root modulo which is :

    >> numlib::primroot(111111111,40487)

                                     111111116

#### Example 4

There are no primitive roots modulo 324013370:

    >> numlib::primroot(324013370)

                                       FAIL

#### Background

- `numlib::primroot` uses `ifactor`.

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000