1.0.0 • Published 9 months ago

fast-mod-exp v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

Fast Mod Exp

Fast modular exponentiation function, for numbers and bigints.

Install

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.

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