@u4/prime
v1.0.1
Published
a simple isPrime, next and prev Prime number implementation in Js.
Maintainers
Readme
@u4/prime
This small package contains simple prime number utilities with no extra stuff.
why an other simple prime number tester / generator
I'm publishing this package because no available prime's number package have the required quality or features to be used. I only need to find some random prime numbers to loop over ℤ/nℤ ring.
I tryed a lot's of implementations
| Name | Size in node_modules | Observation | |------------------------------------------------------------|-----------------------|---------------------------------------------------------------------| | prime-number | 28kB | store all vistited values in memory, contains only isPrime function | | nprime | 776kB | too large + recursive implenetation | | prime-nummers| 4840kB | 4840 KB WTF !! | | prime-q | 54280kB | 54MB !! | | prime-number-boolean | 24kB | using +1 loop + dirty code | | is-prime-number | 24kB | using +1 in test loop + have typing | | prime-number-search | 48kB | works with string but do not support big numbers so, useless | | prime_numbers | 16kB | console.log results +1 loop, do not return result ! |
How it works
Using default import
import isPrime from '@u4/prime';
console.log(isPrime(7))
Using named import
import {isPrime, nextPrime, prevPrime} from '@u4/prime';
console.log(isPrime(7))
Using * as import
import * as Prime from '@u4/prime';
console.log(Prime.isPrime(7))