npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ready-primes-extended

v1.0.3

Published

Get Primes in milliseconds. Pre-calculated collections of prime numbers, natural numbers with distinguished primes and methods to retrieve them.

Downloads

14

Readme

ReadyPrimes Extended

Pre-calculated collections of prime numbers, natural numbers with distinguished primes and methods to retrieve them.

Get any number of Primes in milliseconds !!!

Extended version is limited to 3,001,134 primes and 50,000,000 integers. If you need less get ReadyPrimes (Standard)


Install

ReadyPrimes will generate necessary files post install.

npm install ready-primes-extended

Usage

const ReadyPrimes = require('ready-primes').ReadyPrimes;

ReadyPrimes.primes(4).then( (result) => {
    console.log(result);
    // output: [ 2, 3, 5, 7 ]
});

ReadyPrimes.integers(7).then( (result) => {
    console.log(result);
    // output: [ 0, 0, 1, 1, 0, 1, 0, 1 ]
});

ReadyPrimes.isPrime(11).then( (result) => {
    console.log(result);
    // output: true
});

Methods

primes ( size, index? )

size: int - length of desired result array
index: int (optional) - start position. Default is 0
returns: Promise < int[] >

ReadyPrimes.primes(4).then( (result) => {
    console.log(result);
    // output: [ 2, 3, 5, 7 ]
});

ReadyPrimes.primes(4, 2).then( (result) => {
    console.log(result);
    // output: [ 5, 7, 11, 13 ]
});

integers ( size, index? )

size: int - the length of desired result array
index: int (optional) - start position. Default is 0
returns: Promise < int[] >

The result is an Array of 1's and 0's, where the index inside the Array determines the actual integer. The length of the result is always size + 1, since Array indexes start from 0.

Example: Array[11] = 1, because it is a prime
Array[12] = 0, because it is not a prime

ReadyPrimes.integers(7).then( (result) => {
    console.log(result);
    // output: [ 0, 0, 1, 1, 0, 1, 0, 1 ]
});

ReadyPrimes.integers(7, 2).then( (result) => {
    console.log(result);
    // output: [ 1, 1, 0, 1, 0, 1, 0, 1 ]
});

isPrime ( n )

n: int - number to look-up
returns: Promise < boolean >

ReadyPrimes.isPrime(11).then( (result) => {
    console.log(result);
    // output: true
});