Gathering detailed insights and metrics for @sigma-js/primes
Gathering detailed insights and metrics for @sigma-js/primes
npm install @sigma-js/primes
Typescript
Module System
Node Version
NPM Version
73.7
Supply Chain
99.4
Quality
76.1
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
3,365
Last Day
2
Last Week
13
Last Month
79
Last Year
638
1 Stars
165 Commits
1 Forks
1 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.3
Package Id
@sigma-js/primes@1.0.3
Unpacked Size
49.65 kB
Size
9.10 kB
File Count
7
NPM Version
8.19.2
Node Version
18.12.1
Publised On
28 Oct 2023
Cumulative downloads
Total Downloads
Last day
-93.5%
2
Compared to previous day
Last week
-61.8%
13
Compared to previous week
Last month
259.1%
79
Compared to previous month
Last year
-76.6%
638
Compared to previous year
1
@sigma-js/primes is a javascript library that enables fast detection of prime numbers and prime number arithmetic with the following characteristics.
Install with npm:
1$ npm i @sigma-js/primes
1const { isPrime, isCoprime, getPrimes … } = require("@sigma-js/primes");
1import { isPrime, isCoprime, getPrimes … } from "@sigma-js/primes";
1// You can default settings can be changed 2init({ sieveType: "atkin" }); // default: { sieveType: "eratosthenes" } -> after setting: { sieveType: "atkin" } 3init({ minNum: 1234567 }); // default: { minNum: 1 } -> after setting: { minNum: 1234567 } 4init({ maxNum: 8901234 }); // default: { maxNum: 8388607 } -> after setting: { maxNum: 8901234 } 5init({ sieveType: "atkin", minNum: 1234567, maxNum: 8901234 }); // set all at once
1// You can get the result if the specified number is prime. 2isPrime(3); // Output: true 3isPrime(8); // Output: false 4isPrime(8388607); // Output: false
1// You can get the result if the given numbers are coprime. 2isCoprime(15, 28); // Output: true 3isCoprime(8, 12); // Output: false
1// You can specify a range and get the prime numbers in that range. 2init({ minNum: 100, maxNum: 150 }); // Set maximum value to 100 and maximum value to 150 3getPrimes(); // Range: 100~150, Output: [101, 103, 107, 109, 113, 127, 131, 137, 139, 149] 4getPrimes(125); // Range: 125~150, Output: [127, 131, 137, 139, 149] 5getPrimes(110, 140); // Range: 110~140, Output: [113, 127, 131, 137, 139]
1// You can get the average of prime numbers within a specified range. 2init({ maxNum: 30 }); // Set the maximum value to 30 3getPrimesAverage(); // Range: 1~30, Rounded to third decimal places, Output: 12.9 4getPrimesAverage(25); // Range: 25~30, Rounded to third decimal places, Output: 29 5getPrimesAverage(5, 30); // Range: 5~30, Rounded to third decimal places, Output: 15.5 6getPrimesAverage(1, 5, 9); // Range: 1~5, Rounded to the ninth decimal place, Output: 3.333333333 7getPrimesAverage(5, 12, 9); // Range: 5~12, Rounded to the ninth decimal place, Output: 7.666666667 8getPrimesAverage(5, 12, 0); // Range: 5~12, Rounded to the first decimal place, Output: 8
1// You can get the number of prime numbers in a specified range. 2init({ maxNum: 20 }); // Set the maximum value to 20 3getPrimesCount(); // Range: 1~20, Output: 8 4getPrimesCount(6); // Range: 6~20, Output: 5 5getPrimesCount(1, 10); // Range: 1~10, Output: 4
1// You can get the correct index of prime numbers in a given range. 2init({ maxNum: 25 }); // Set the maximum value to 25 3getPrimesIndex(3); // Range: 1~25, Output: 2 4getPrimesIndex(17, 10); // Range: 10~25, Output: 3 5getPrimesIndex(2, 1, 10); // Range: 1~10, Output: 1
1// You can get the number of prime numbers in a specified range. 2init({ maxNum: 100 }); // Set the maximum value to 100 3getPrimesMedian(); // Range: 1~100, Output: 41 4getPrimesMedian(25); // Range: 25~100, Output: 60 5getPrimesMedian(5, 34); // Range: 5~34, Output: 17 6getPrimesMedian(5, 50); // Range: 5~50, Output: 23
1// You can get the sum of prime numbers within a specified range. 2init({ maxNum: 30 }); // Set the maximum value to 30 3getPrimesSum(); // Range: 1~30, Output: 129 4getPrimesSum(25); // Range: 25~30, Output: 29 5getPrimesSum(5, 30); // Range: 5~30, Output: 124
1// You can get twin prime numbers within a specified range. 2init({ maxNum: 20 }); // Set the maximum value to 20 3getPrimesTwins(); // Range: 1~20, Output: [[3, 5],[5, 7],[11, 13],[17, 19]] 4getPrimesTwins(6); // Range: 6~20, Output: [[11, 13],[17, 19]] 5getPrimesTwins(1, 10); // Range: 1~10, Output: [[3, 5],[5, 7]] 6getPrimesTwins(3, 4); // Range: 3~4, Output: []
1// You can obtain the prime factorization result of the specified number. 2getFactors(24); // Output: [2, 2, 2, 3] 3getFactors(555); // Output: [3, 5, 37]
1// You can get the prime factorization result of the specified number using a formula. 2getFactorsFormula(24); // Output: "2^3*3" 3getFactorsFormula(30); // Output: "2*3*5" 4getFactorsFormula(7); // Output: "7"
1// You can get the multiplicative inverse of a given number. 2getMultInverse(3, 11); // Output: 4 (Get x that becomes 3*x≡1(mod 11)) 3getMultInverse(7, 13); // Output: 2 (Get x that becomes 7*x≡1(mod 13))
1// You can get prime numbers randomly within a specified range. 2init({ maxNum: 100 }); // Set the maximum value to 100 3getRandomPrime(); // Range: 1~100, Output: 7 4getRandomPrime(10); // Range: 10~100, Output: 11 5getRandomPrime(4, 12); // Range: 4~12, Output: 5
Copyright (c) 2023, s-hama. Released under the MIT License.
No vulnerabilities found.
No security vulnerabilities found.