eratosthenes

1.0.0 • Public • Published

eratosthenes

An implementation of the sieve of Eratosthenes to find prime numbers.

Why? No, friend…Why not?!

It calculates the primes between 2 and 1M in about 8 seconds on my hardware. I feel pretty good about that.

Usage

If installed globally, this module can be called from the command line like this:

sieve [n]

where n is an integer. sieve will calculate all the primes from 2 to n and will print out a list and the number of primes it found.

Functions

If installed as a module in another project, this utility provides the following functions.

setDifference(a, b)

Takes two arrays (a and b) and returns an array of the set difference (A\B).

findPrimes(num)

Returns an array of all the prime numbers between 2 and num.

Requirements

This module uses lodash.range because Python has spoiled me.

Readme

Keywords

none

Package Sidebar

Install

npm i eratosthenes

Weekly Downloads

0

Version

1.0.0

License

GPL-3.0

Last publish

Collaborators

  • bactroid