# fast-mod-exp

> Fast modular exponentiation function, for numbers and bigints.

Latest version **1.0.1** (published 2025-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install fast-mod-exp
pnpm add fast-mod-exp
yarn add fast-mod-exp
bun add fast-mod-exp
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2025-01-13 |
| First published | 2023-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | fabiospampinato |
| Keywords | fast, modular, exponentiation |

## Links

- npm: https://www.npmjs.com/package/fast-mod-exp
- Repository: https://github.com/fabiospampinato/fast-mod-exp
- Homepage: https://github.com/fabiospampinato/fast-mod-exp#readme
- Issues: https://github.com/fabiospampinato/fast-mod-exp/issues
- npm.io page: https://npm.io/package/fast-mod-exp

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2025-01-13
- 1.0.0 — 2023-08-05

## README

# Fast Mod Exp

Fast modular exponentiation function, for numbers and bigints.

## Install

```sh
npm install fast-mod-exp
```

## Usage

This is equivalent to doing `( a ** b ) % n`, assuming bigints or infinite precision, but way faster in many cases.

```ts
import fme from 'fast-mod-exp';

{ // It works with numbers
  const a = 123;
  const b = 23;
  const n = 531;
  const result = fme ( a, b, n ); // => 171
}

{ // It works with bigints also
  const a = 123n;
  const b = 23n;
  const n = 531n;
  const result = fme ( a, b, n ); // => 171n
}
```

## License

MIT © Fabio Spampinato

---
_Source: https://npm.io/package/fast-mod-exp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
