![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
prime-functions
Advanced tools
Advanced Prime Numbers Functions. All functions that you need. Generate primes and process with prime numbers
Primes are of the utmost importance to number theorists because they are the building blocks of whole numbers, and important to the world because their odd mathematical properties make them perfect for our current uses. On that matter we've built a library to create and find prime numbers
You can play with the functions on prime-functions.truncgil.com
npm install prime-functions
const pr = require('prime-functions');
console.log(pr.isPrime(13)); //true
You can simply use the prime-functions
on the client side:
<script src="https://cdn.jsdelivr.net/npm/prime-functions/index.min.js"></script>
<script>
const pr = primeFunctions;
console.log(pr.isPrime(13)); //true
</script>
Return if a number is Prime Number
let result = pr.isPrime(13); // true
let result = pr.isPrime(28); // false
Get nth prime
let result = pr.nthPrime(5); // 11
Get index of prime number
let result = pr.indexOfPrime(13); // 5
Index starts from 0
let result = pr.nthPrimesSum(3,5,7); // 5 + 11 + 17 = 33
let result = pr.nthPrimesTimes(3,5,7); // 5 * 11 * 17 = 935
let result = pr.nextPrime(17); // 19
let result = pr.prevPrime(17); // 13
let result = pr.primeSmallerThan(100); // 97
let result = pr.primeBiggerThan(100); // 101
let result = pr.primeDivisors(42); // [2,3,7]
let result = pr.primeDivisorsSum(42); // 2 + 3 + 7 = 12
let result = pr.primeDivisorsTimes(42); // 2 * 3 * 7 = 42
Checks if a prime is a Mersenne Prime
let result = pr.isMersennePrime(127); // true
Get nth Mersenne Prime
let result = pr.nthMersennePrime(5); // 8191
Get nth Mersenne Prime's exponents
let result = pr.nthMersennePrimeExponents(5); // 13 - That means 2^13
If the number is prime it returns true, otherwise it returns prime divisors
let result = pr.primesSmallerThan(25); // [ 2, 3, 5, 7, 11, 13, 17, 19, 23 ]
let result = pr.closestPrime(25); // 23
let result = pr.randomPrime(25, 48); // 31
let result = pr.whatWillThisPrimeBe(23); // It'll strengthen you
let result = pr.nextNPrimes(25, 5); // [ 29, 31, 37, 41, 43 ]
let result = pr.prevNPrimes(25, 5); // [ 23, 19, 17, 13, 11 ]
let result = pr.primesBetween(80, 150); // [ 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149 ]
let result = pr.firstNPrimes(7); // [ 2, 3, 5, 7, 11, 13, 17 ]
helper function
let result = pr.digits(1554); // 4
helper function
let result = pr.sum([2,3,4]); // 9
helper function
let result = pr.times([2,3,4]); // 24
helper function
let result = pr.remainDividedBy(8,3); // 2
helper function That should be bottom of the script
pr.printExecutionTime(); // Execution time: 119ms
helper function
pr.beautifyInteger(123123123); // 123.123.123
helper function
pr.reverseNumber(123456); // 654321
helper function
pr.integerToText(1234567890); // bcdefghija
helper function
pr.integerToString(1234567890); // '1234567890'
helper function
pr.integerToArray(1234567890); // ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
helper function
Returns number first n digits
pr.firstNDigits(1234567890, 4); // 1234
helper function
Returns number last n digits
pr.lastNDigits(1234567890, 4); // 7890
returns if the given number is emirp.
pr.isEmirp(13); // true
pr.isEmirp(31); // true
pr.isEmirp(19); // false
returns nth emirp. 1 is the 11
pr.nthEmirp(2); // 13
pr.nthEmirp(5); // 37
check if the prime has a twin
pr.hasTwinPrime(3); // 5
pr.hasTwinPrime(5); // [5, 7]
pr.hasTwinPrime(311); // 313
pr.hasTwinPrime(3, false); // True
pr.hasTwinPrime(37); // false
helper
pr.factorial(3); // 6
pr.factorial(pr.factorial(3)); // 720
The Wilson's Theorem.
n+1 should be prime number if and only if n! mod(n+1) = n.
returnWithExplanation is the conditions and explanation of Wilson's Theorem.
pr.wilsonsTheorem(6);
/*
{
formula: 'FORMULA: f(n) = ( 6! mod(6+1) / n ) * ( 6+1 ) + 2 --- CONDITIONS: if 6+1 is prime if and only if 6! mod(6+1) = 6 ',
result: 7
}
*/
pr.wilsonsTheorem(6, false); // 7
Euler's phi and also known as totient function.
Function can be used as both phi and totient
pr.totient(1) // 1
pr.phi(2) // 1
pr.phi(3) // 2
pr.phi(4) // 2
pr.totient(5) // 4
pr.phi(6) // 2
pr.phi(7) // 6
pr.totient(8) // 4
pr.phi(9) // 6
pr.phi(10) // 4
Check if the given number is Truncatable Prime
pr.isTruncatable(3797); //true
pr.isTruncatable(373); //true
pr.isTruncatable(23); //false
Returns number's Truncatable values
pr.truncatableValues(3797);
/*
{
leftToRight: [ 3, 37, 379, 3797 ],
rightToLeft: [ 7, 97, 797, 3797 ]
}
*/
Finds the nth Truncatable Prime
pr.nthTruncatablePrime(10); // 3797
Checks if the given number is Pandigital Prime
pr.isPandigitalPrime(2143); // true
FAQs
Advanced Prime Numbers Functions. All functions that you need. Generate primes and process with prime numbers
The npm package prime-functions receives a total of 3 weekly downloads. As such, prime-functions popularity was classified as not popular.
We found that prime-functions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.