Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabiospampinato/fast-mod-exp
Fast modular exponentiation function, for numbers and bigints.
https://github.com/fabiospampinato/fast-mod-exp
expression fast modular
Last synced: about 2 months ago
JSON representation
Fast modular exponentiation function, for numbers and bigints.
- Host: GitHub
- URL: https://github.com/fabiospampinato/fast-mod-exp
- Owner: fabiospampinato
- License: mit
- Created: 2023-08-05T12:24:00.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-09-24T16:28:49.000Z (over 1 year ago)
- Last Synced: 2024-11-21T23:16:29.422Z (about 2 months ago)
- Topics: expression, fast, modular
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Fast Mod Exp
Fast modular exponentiation function, for numbers and bigints.
## Install
```sh
npm install --save 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 bigints
const a = 123n;
const b = 23n;
const n = 531n;
const result = fme ( a, b, n ); // => 171n
}{ // It works with numbers also
const a = 123;
const b = 23;
const n = 531;
const result = fme ( a, b, n ); // => 171
}
```## License
MIT © Fabio Spampinato