Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fast-prime-client

ganeshkbhat47MIT0.1.0

Fastest Prime Number Calculation logic for browser (checks, random generator, prime range generator, primes count generator, summation of primes, factorial of primes)

Fastest, Prime, Number, Calculation, fast primes, fast prime, fast, primes, numbers, prime numbers, prime, primes, get prime, get primes, fetch prime, fetch primes, check prime, check primes, fast prime, fast primes, multiple prime calculation methods, aks prime calculation methods, Mersenne prime calculation methods, Fermat's little theorem prime calculation methods, Conventional prime calculation methods, count, fetch all primes from count of numbers, range, fetch all primes from range of numbers, summation, summation of prime number, summation of prime numbers, fetch summation of all primes from range of numbers, fetch factorial of all primes from range of numbers, fetch summation of all primes from count of prime numbers, fetch factorial of all primes from count of prime numbers, factorial, factorial of prime number, factorial of prime numbers, node.js, nodejs, javasript, browser, client, prime, primes, primenumber, prime number, prime numbers, math, sum prime, sum primes, sum-prime, sum-primes, prime-js, prime js, primes-js, nprime, primality, primality test, naive test, primesnext, primeprevious, primes next, prime previous, primeutil, prime util, primes-simple, primes simple, prime factorization, factorization, numbersprimality, numbers primality, simple-prime-generator, simple prime generator, fast-prime-generator, fast prime generator, ready-primes, ready primes, stored-primes, stored primes, integer-sequences, integer prime sequences, oeis, math, mathematic, integer, sequence, series, squares, square, triangle, triangularnumbers, triangular numbers, prime helpers, primes helper, primes helpers, ready-primes-extended, ready primes extended, stored-primes-extended, stored primes extended, prime-fun, primes-fun, prime fun, primes fun, math-iter-sequences-primes, math iter sequences primes, math-iterator-sequences-primes, math iterator sequences primes, math-generator-sequences-primes, math generator sequences primes, stdlib, std, mathmathematics, math primes, prime integer, int, prime number sequences, prime number iterator, iterate iteration, iter, gen, generator, prime generator, primes generator, datasets-primes-100k, datasets primes 100k, datasets primes number 100k, datasets-primes-10k, datasets primes number 10k, datasets-primes-1000k, datasets primes 1000k, fast prime generator, generate primes in milliseconds, dataset, datasets,Balanced primes, Bell primes, Chen primes, Circular primes, Cluster primes, Cousin primes, Cuban primes, Cullen primes, Dihedral primes, Eisenstein primes without imaginary part, Emirps, Euclid primes, Euler irregular primes, Euler (p, p − 3) irregular primes, Factorial primes, Fermat primes, Generalized Fermat primes, Fibonacci primes, Fortunate primes, Gaussian primes, Good primes, Happy primes, Harmonic primes, Higgs primes for squares, Highly cototient primes, Home primes, Irregular primes, irregular primes, irregular primes, irregular primes, Isolated primes, Leyland primes, Long primes, Lucas primes, Lucky primes, Mersenne primes, Mersenne divisors, Mersenne prime exponents, Double Mersenne primes, Generalized repunit primes, Other generalizations and variations, Mills primes, Minimal primes, Newman–Shanks–Williams primes, Non-generous primes, Palindromic primes, Palindromic wing primes, Partition primes, Pell primes, Permutable primes, Perrin primes, Pierpont primes, Pillai primes, Primes of the form n4 + 1, Primeval primes, Primorial primes, Proth primes, Pythagorean primes, Prime quadruplets, Quartan primes, Ramanujan primes, Regular primes, Repunit primes, Residue classes of primes, Safe primes, Self primes in base 10, Sexy primes, Smarandache–Wellin primes, Solinas primes, Sophie Germain primes, Stern primes, Super-primes, Supersingular primes, Thabit primes, Prime triplets, Truncatable prime, Left-truncatable, Right-truncatable, Two-sided, Twin primes, Unique primes, Wagstaff primes, Wall–Sun–Sun primes, Weakly prime numbers, Wieferich primes, Wilson primes, Wolstenholme primes, Woodall primes, https://en.wikipedia.org/wiki/List_of_prime_numbers, prime decomposition, prime factors, bricks,factorization,javascript,js,numberprime, number prime, give-me-prime, prime-number, PrimeSwap, prime-js, prime js, fm-primes, prime-package-for-primes, prime package for primes, fast-primes, fast primes, Fast Prime Gen, Fast Prime Generator, parsegraph-primes, test-primegenerator, test prime generator, primes-multiplication-table, primes multiplication table, cached, prime number lookup, fm-prime-js, fm prime js, fm-prime-py, fm prime py, primespice, prime spice, fast-prime-gen, fast-prime-generator, fast prime gen, fast prime generator, primes-and-factors, primes and factors, primes factors number, primes-factors-number, get-primes, get primes, prime-package-for-primes, prime package for primes, prime package, prime package for primes, prime package for prime numbers, prime package for prime number, prime-package-for-primes, @number-theoretic/primes, number theoretic primes, primeget, prime get, primes get, prime-lib, prime lib, primes-simple, primes simple, get-primes, fast-primes, primes-fast, primes fast, primes get, pregenerated-primes, pregenerated primes, primes pregenerated, prime-functions, functions prime, Advanced Prime Numbers Functions, cached-primes, primes-cached, cached primes, is prime, isprime, test-primegenerator, test prime generator, prime generator, prime tests, primality tests, sum primes, factorial primes, range of primes, get range of primes, get sum of primes, get factorial of primes, random primes, get counts or numbers of primes, get counts or numbers of prime, get range or numbers of primes between range, get next prime, get previous prime, next prime, previous prime, primes generator function, stored primes, primes json file, prestored primes json file, precalculated primes json file

readme

Fast Prime Calculations

Fastest Prime Number Calculation logic (checks, random generator, prime range generator, primes count generator, summation of primes, factorial of primes, primes generator)

This probably is the BEST solution in the internet as of today 11th March 2022

This same code can be applied in any languages like Python, Go Lang, Java, PHP, Node.js, Javascript, C, C++, .NET, Rust, etc with the same logic and have performance benefits. It is pretty fast based on the number of iterations needed. Performance time checks were not consistent across languages (in my local system - to be direct about wordings). I have not seen this implemented before and has been indigenously done. Feedback and usage is welcome.

Max iterations 16666 for n == 100000 instead of 100000 of conventional way. The iterations counts for different ways for Prime number check 100007 can be seen as follows:

    count: Prime Conventional way for  83 is  81
    Is Prime 83 isPrimeConventionalWay:  True

    count: Prime Squareroot way  83 is  8
    Is Prime 83 isPrimeSquarerootWay:  True

    count: Prime Unconventional way for  83 is  14
    Is Prime 83 prime (SUGGESTED):  True

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  83 is  2
    Is Prime 83 isprimeAKSWay:  True

    count: Prime Conventional way for  169 is  12
    Is Prime 169 isPrimeConventionalWay:  False

    count: Prime Squareroot way  169 is  12
    Is Prime 169 isPrimeSquarerootWay:  False

    count: Prime Unconventional way for  169 is  1
    Is Prime 169 prime (SUGGESTED):  False

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  169 is  4
    Is Prime 169 isprimeAKSWay:  False

    count: Prime Conventional way for  100007 is  96
    Is Prime 100007 isPrimeConventionalWay:  False

    count: Prime Squareroot way  100007 is  96
    Is Prime 100007 isPrimeSquarerootWay:  False

    count: Prime Unconventional way for  100007 is  15
    Is Prime 100007 prime (SUGGESTED):  False

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  100007 is  32
    Is Prime 100007 isprimeAKSWay:  False

    count: Prime Conventional way for  300530164787 is  1180
    Is Prime 300530164787 isPrimeConventionalWay:  False

    count: Prime Squareroot way  300530164787 is  1180
    Is Prime 300530164787 isPrimeSquarerootWay:  False

    count: Prime Unconventional way for  300530164787 is  196
    Is Prime 300530164787 prime (SUGGESTED):  False

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  300530164787 is  393
    Is Prime 300530164787 isprimeAKSWay:  False

Code Base

Javascript

Javascript Codebase

  • Access Node code using require("fast-prime")
  • Access client (browser code) for just basic prime checks using ./node_modules/src/client/primes.js and node_modules/src/client/primes.min.js
  • Access client (browser code) using ./node_modules/src/client/primes.all.js and node_modules/src/client/primes.all.min.js
  • Access client (browser code) using cdn https://unpkg.com/fast-prime@{version}/src/client/primes.all.js. Example https://unpkg.com/fast-prime@0.0.64/src/client/primes.all.min.js
  • Access client (browser code) smaller non optimised size using ./node_modules/src/client/primes.ip.js and node_modules/src/client/primes.ip.min.js
  • Access client (browser code) smaller non optimised using cdn https://unpkg.com/fast-prime@{version}/src/client/primes.ip.js. Example https://unpkg.com/fast-prime@0.0.64/src/client/primes.ip.min.js
  • Demos

Features of the Library

  • Different ways of prime number checks (isprime)

      - Fast prime (Recommended innovative function)
    
      - Iterative/Recursive (Conventional iterative way)
    
      - SquareRoot (AKS - Mersenne primes - Fermat's little theorem)
  • Different ways of getting primes (using all above different ways)

      - Fetch prime between two number range (min - max)
    
      - Fetch counts (numbers) of prime starting from any number
    
      - Random prime number generator [TODO]
    
      - Optimized function with pre-calculated stored values (< 10000, < 100000, < 1000000)
    
              - Stored value calculation Failover to JIT calculation using above formulaes
  • Different ways of getting summation of primes (using all above different ways)

      - Fetch summation of prime between two number range (min - max)
    
      - Fetch summation of counts (numbers) of prime starting from any number
    
      - Fetch summation of Custom array provided [TODO]
    
      - Fetch factorial - Optimized function with pre-calculated stored values (< 10000, < 100000, < 1000000)
    
              - Stored value calculation Failover to JIT calculation using above formulaes
  • Different ways of getting factorial of primes (using all above different ways)

      - Fetch factorial of prime between two number range (min - max)
    
      - Fetch factorial of counts (numbers) of prime starting from any number
    
      - Fetch factorial of Custom array provided [TODO]
    
      - Fetch factorial - Optimized function with pre-calculated stored values (< 10000, < 100000, < 1000000)
    
              - Stored value calculation Failover to JIT calculation using above formulaes


// Usage API for client
// Check demos folder for usage in the github repos
// https://github.com/ganeshkbhat/fastprimenumbers/tree/main/nodejs/demos


primes().fast // Recommended or Suggested way
primes().primes // Recommended or Suggested way
primes().recursive
primes().sqrootExpressive
primes().sqroot

primesCount().alternateWays
primesCount().alternateWaysOptimized (async - promise)
primesCount().fast
primesCount().fastOptimized (async - promise)

primesRange().alternateWays
primesRange().alternateWaysOptimized (async - promise)
primesRange().fast
primesRange().fastOptimized (async - promise)

primesSum().alternateWaysCount
primesSum().alternateWaysCountOptimized (async - promise)
primesSum().alternateWaysRange
primesSum().alternateWaysRangeOptimized (async - promise)
primesSum().fastCount
primesSum().fastCountOptimized (async - promise)
primesSum().fastRange
primesSum().fastRangeOptimized (async - promise)

primesFactorial().factorial
primesFactorial().alternateWaysCount
primesFactorial().alternateWaysCountOptimized (async - promise)
primesFactorial().alternateWaysRange
primesFactorial().alternateWaysRangeOptimized (async - promise)
primesFactorial().fastCount
primesFactorial().fastCountOptimized (async - promise)
primesFactorial().fastRange
primesFactorial().fastRangeOptimized (async - promise)

Python

Python Codebase

Stack overflow Link for Calculations

LICENSE

Custom Crediting License PROPRIETARY LICENSE AGREEMENT ONLY

TODO

  • [D] Add summation of array of primes using (range, count)
  • Add summation of array of primes using custom prime numbers
  • [D] Add factorial of array of primes using (range, count)
  • Add factorial of array of primes using custom prime numbers
  • Consider adding random prime generator
  • Consider adding generator using generator functions
  • [D] Consider adding fetching primes from remote api for stored primes
  • Consider adding support for very large prime numbers (checks, range, count, sum, factorial, random) and related generators
  • Consider adding support for very large random prime generator
  • Adding following (all) APIs to Javascript, Typescript, Python, Java
  • Adding all APIs to Go, TS (Consider C#, Rust, C, Cpp)
  • Consider adding function to library