(n: bigint)
| 1021 | // MAX_VALUE_SCALED_ITERATIONS). |
| 1022 | if (steps > MAX_VALUE_SCALED_ITERATIONS) |
| 1023 | throw new CancellationError({ |
| 1024 | message: `PrimitiveRoot: exceeded ${MAX_VALUE_SCALED_ITERATIONS} iterations`, |
| 1025 | cause: 'iteration-limit-exceeded', |
| 1026 | }); |
| 1027 | } |
| 1028 | if (gcd(a, n) !== 1n) continue; |
| 1029 | if (phiFactors.every((q) => modPow(a, phi / q, n) !== 1n)) |
| 1030 | return ce.number(a); |
| 1031 | } |
| 1032 | return undefined; |
| 1033 | }, |
| 1034 | }, |
| 1035 | |
| 1036 | PrimeNumber: { |
| 1037 | description: |
| 1038 | 'The nth prime number. `PrimeNumber` is an alias for `NthPrime`, which is the preferred name.', |
| 1039 | signature: '(integer) -> integer', |
| 1040 | canonical: ([n], { engine }) => engine._fn('NthPrime', [n]), |
| 1041 | }, |
no test coverage detected