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

integer-sequences

v1.0.4

Published

Functional library for precise access to integer sequences such as prime numbers, square numbers, triangle numbers, etc

Downloads

41

Readme

integer-sequences

build coverage npm dependencies downloads

Functional library for precise access to integer sequences such as prime numbers, square numbers, triangle numbers, etc

Intro

npm install --save integer-sequences

Functional library for precise access to integer sequences. Total unit test coverage. Cached access offers performance. For example:

const intseqs = require('integer-sequences')
intseqs.prime.sequenceMax(100000000)  // takes 1900ms - first call
intseqs.prime.sequenceMax(100000000)  // takes 25ms - second cached call

It makes use of Big.js to guarantee precision when working with big numbers.

Numeric arguments can be given as:

  • strings - e.g. intseqs.prime.isTerm('1000000')
  • Big.js objects - e.g. intseqs.prime.isTerm(Big('1000000')) or intseqs.prime.isTerm(Big(1000000))
  • numbers - e.g. intseqs.prime.isTerm(1000000)

Function return values are typically Big.js objects. To access a Big.js object value:

const intseqs = require('integer-sequences')
const bigObj = intseqs.prime.term(10)
const value = bigObj.toFixed()
console.log(value) // logs '29'

Misc functions

intseqs.getNumbersAsJson(max: number)  // Returns a list of numeric JSON objects

Example:

intseqs.getNumbersAsJson(7)

Returns:

Prime values returned may be of type number for performance reasons.

intseqs.getNumberAsJson(n: number)  // Returns the nth numeric JSON object

Prime numbers - A000040

term - isTerm - isTermFast

Full support for primes upto Prime(6000000)=104395301 (partial support thereafter)

intseqs.prime.sequence(n: number)       // Returns a list of the first n terms in the sequence
intseqs.prime.sequenceMax(max: number)  // Returns a list of the first terms, all terms being <= max
intseqs.prime.term(n: number)           // Returns the nth term
intseqs.prime.isTerm(n: number)         // Returns x where n is the xth term or false where n is not a term
intseqs.prime.isTermFast(n: number)     // Returns a boolean, is n a term?

Cube numbers - A000578

term isTerm

intseqs.cube.sequence(n: number)
intseqs.cube.sequenceMax(max: number)
intseqs.cube.term(n: number)
intseqs.cube.isTerm(n: number)

Fibonacci numbers - A000045

term isTerm isTermFast

intseqs.fibonacci.sequence(n: number)
intseqs.fibonacci.sequenceMax(max: number)
intseqs.fibonacci.term(n: number)
intseqs.fibonacci.isTerm(n: number)
intseqs.fibonacci.isTermFast(n: number)

Padovan numbers - A134816

term isTerm

intseqs.padovan.sequence(n: number)
intseqs.padovan.sequenceMax(max: number)
intseqs.padovan.term(n: number)
intseqs.padovan.isTerm(n: number)

Square numbers - A000290

term isTerm

intseqs.square.sequence(n: number)
intseqs.square.sequenceMax(max: number)
intseqs.square.term(n: number)
intseqs.square.isTerm(n: number)

Tetrahedron numbers - A000292

term isTerm

intseqs.tetrahedron.sequence(n: number)
intseqs.tetrahedron.sequenceMax(max: number)
intseqs.tetrahedron.term(n: number)
intseqs.tetrahedron.isTerm(n: number)

Triangle numbers - A000217

term isTerm

intseqs.triangle.sequence(n: number)
intseqs.triangle.sequenceMax(max: number)
intseqs.triangle.term(n: number)
intseqs.triangle.isTerm(n: number)

Author says

People think I am religious but, to my mind, I just love Jesus! People think man-made religion is boring! So do I. Worse than that, man-made religion is destructive. Jesus himself warned against it.

What Jesus wants is relationship; to be your friend. This video explains it fairly well.

Remember, Jesus is alive, and you can be too if you believe in Him and leave your life of sin :)

For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life. For God did not send his Son into the world to condemn the world, but to save the world through him. Whoever believes in him is not condemned, but whoever does not believe stands condemned already because they have not believed in the name of God’s one and only Son.

John 3:16-18

"He is no fool who gives up what he cannot keep to gain that which he cannot lose" Jim Elliot