https://github.com/richienb/modular-power
Find the modulo of a number raised to a power.
https://github.com/richienb/modular-power
Last synced: 10 months ago
JSON representation
Find the modulo of a number raised to a power.
- Host: GitHub
- URL: https://github.com/richienb/modular-power
- Owner: Richienb
- License: mit
- Created: 2020-12-23T04:08:21.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-21T14:20:06.000Z (over 3 years ago)
- Last Synced: 2025-02-18T23:03:53.680Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# modular-power
Find the modulo of a number raised to a power. Similar to the [`pow()`](https://docs.python.org/3/library/functions.html#pow) function in Python.
## Install
```sh
npm install modular-power
```
## Usage
```js
import modularPower from 'modular-power';
modularPower(2, 3, 3);
//=> 2
modularPower(2, 3, 5);
//=> 3
```
## API
### modularPower(base, exponent, modulus)
The type of return value and arguments is determined by whether `base` is a `number` or `BigInt`.
#### base
The number to be raised to an exponent.
#### exponent
The exponent to apply to the base.
#### modulus
The modulus to apply to the exponent of the base.