modulo
Calculates the remainder of a number when divided by another number. In contrast to JavaScript’s % operator, it handles the modulo of negative numbers correctly and only ever returns values between 0 and modulo base - 1.
Installation
npm install @madeinhaus/utilsImport
import { modulo } from '@madeinhaus/utils';Parameters
n(number): The number to calculate the modulo of.m(number): The modulo base.
Returns
- (number): The modulo of
nwith respect tom.
Usage
import { modulo } from '@madeinhaus/utils';
const n = 10;
const m = 3;
const result = modulo(n, m); // 1In this example, we import the modulo function from the @madeinhaus/utils package and use it to calculate the modulo of a number.