GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tsevasa/Primality-Test: Fast primality testing algorithm for javascript (using Miller-Rabin test)

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

21 Commits
21 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
isPrime.js
isPrime.js
 
 

Repository files navigation

Primality testing algorithm

This is a primality testing algorithm written in javascript and geared towards being as fast as possible. It is an adaptation of https://github.com/latonv/MillerRabinPrimality optimized for speed and determinism for "small" inputs.

isPrime.js contains the function primalityTest(n) which returns a boolean value specifying whether n is a probable prime or not, where n can be either a number or a BigInt or a string. Look at the comments in the code for the detailed description of every function and the optional arguments that can be specified.

We employ the Miller-Rabin algorithm, and we utilize the Montgomery modular multiplication method for large inputs above 10³⁰ by default. For inputs below 2⁶⁴, our algorithm was written to be deterministic and always test the optimal bases (see an explanation here). For inputs larger than 2⁶⁴, the algorithm is probabilistic and the number of bases tested is adjusted dynamically by the method getAdaptiveNumRounds(inputBits), finding a good tradeoff between speed and reliability.


This code was adapted by Andreas Tsevas and Naviary for a private project, but feel free to use it as part of your own project if you need a browser to calculate primes in natively written javascript.

About

Fast primality testing algorithm for javascript (using Miller-Rabin test)

Topics

miller-rabinprime-numbers

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.