npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mod-arithmetic-package

v1.0.3

Published

A package with mathematical modular arithmetic operations like add, multiply, divide, etc...

Downloads

6

Readme

Modular Arithmetic Package

Modular Arithmetic Package Logo

A versatile JS package for modular arithmetic operations.

Table of Contents

Introduction

Welcome to the Modular Arithmetic Package! This package provides a set of functions and tools for performing modular arithmetic operations. Whether you're working on cryptography, number theory, or any other field that involves modular arithmetic, this package is designed to simplify your tasks and provide efficient and reliable solutions.

Key features include:

  • Addition, subtraction, multiplication, and exponentiation in modular arithmetic.
  • Modular inverses and modular exponentiation.
  • Compatibility with large integers and customizable modulus values.

Installation

To install the package, use the following npm command:

npm install mod-arithmetic-package

Usage

To use the package in your JS project, import the mod-arithmetic-package module:

import { mod_add } from 'mod-arithmetic-package';

Examples

  • Performing modular addition
    • import { mod_add } from 'mod-arithmetic-package';
          
      let a = 2, b = 3, MOD = 5;
          
      console.log(mod_add(a, b, MOD)) // -> 0;
      console.log(mod_add(a, b)) // MOD=1e9+7 by default -> 5;
  • Performing modular subtraction
    • import { mod_sub } from 'mod-arithmetic-package';
          
      let a = 1, b = 3, MOD = 1e9 + 7;
          
      console.log(mod_sub(a, b, MOD)) // -> 1000000005;
      console.log(mod_sub(a, b)) // MOD=1e9+7 by default -> 1000000005;
  • Performing modular multiplication
    • import { mod_mul } from 'mod-arithmetic-package';
          
      let a = 1, b = 3, MOD = 2;
          
      console.log(mod_mul(a, b, MOD)) // -> 1;
      console.log(mod_mul(a, b)) // MOD=1e9+7 by default -> 3;
  • Performing modular division
    • import { mod_div } from 'mod-arithmetic-package';
          
      let a = 1, b = 2, MOD = 1e9 + 7;
          
      console.log(mod_div(a, b, MOD)) // -> 500000004;
      console.log(mod_div(a, b)) // MOD=1e9+7 by default -> 500000004;
  • Performing multiplicative modular inverse
    • import { mod_inv } from 'mod-arithmetic-package';
          
      let a = 5, MOD = 1e9 + 7;
          
      console.log(mod_inv(a, MOD)) // -> 400000003;
      console.log(mod_inv(a)) // MOD=1e9+7 by default -> 400000003;
  • Performing binary exponentiation (modular power)
    • import { mod_pow } from 'mod-arithmetic-package';
          
      let a = 2, b = 32, MOD = 1e9 + 7;
          
      console.log(mod_pow(a, b, MOD)) // -> 294967268;
      console.log(mod_pow(a, b)) // MOD=1e9+7 by default -> 294967268;

License

This package is licensed under the MIT License. Feel free to use it in your projects.