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

antiprime

v1.0.6

Published

Because sometimes we need highly composite numbers

Downloads

5

Readme

antiprime

Build Status Coverage Status GitHub issues NPM Licence npm bundle size npm total downloads npm version

Because sometimes we want highly composite numbers.

Installation

npm i --save antiprime

Usage

JavaScript

const { isHighlyComposite } = require('antiprime');
const hc = isHighlyComposite(12);
console.log(hc); //Outputs: true

TypeScript

import { Antiprime } from 'antiprime';
const ap = new Antiprime(33);
console.log(ap.isAntiprime()); //Outputs: false

API

new Antiprime(n);
new HighlyCompositeNumber(n); //alias

Creates a new Antiprime class object.

Properties

value

The positive integer value currently stored in the Antiprime object.

Functions

previousAntiprime()
previousHighlyCompositeNumber() //alias

Returns a new Antiprime object where value is equal to the next lowest Antiprime number.

nextAntiprime()
nextHighlyCompositeNumber() //alias

Returns a new Antiprime object where value is equal to the next largest Antiprime number.

getFactors()

Returns an array of numbers that include all factors including the 1 and value.

getPrimeFactors()

Returns an array of objects with properties factor and exponent of all prime factors.


As well as the Antiprime class, there are exported functions that can used to test numbers without calculating other properties.

Functions

factors(n)

Takes an input integer n and returns all factors of the input as an array of numbers.

isAntiprime(n, pf)
isHighlyComposite(n, pf) //alias

Takes an input integer n and returns true if the input is highly composite; false otherwise. Optional input pf is the output to the primeFactors function. This is provided to reduce computational overhead in the case that primeFactors has been calculated for n previously.

isAntiprimeCandidate(n, pf)

Takes an input integer n and returns true if the input is a candidate for a highly composite number; false otherwise. Optional input pf is the output to the primeFactors function. This is provided to reduce computational overhead in the case that primeFactors has been calculated for n previously.

A candidate is a number that meets the following criteria:

  • The k prime factors are equal to the first k prime numbers.
  • The exponent of each prime factor does not increase as the magnitude of prime factors increases.
  • The exponent of the final prime factor is 1.
  • n is one of the special cases: 4 or 36.
isConsecutivePrimeFactors(pf)

Takes the output of primeFactors and returns true if the k prime factors are equal to the first k prime numbers; false otherwise.

isPrime(n)

Returns true if the input number n is prime; false otherwise.

isPrimeExponentsReducing(pf)

Takes the output of primeFactors and returns true if the exponent of each prime factor does not increase as the magnitude of prime factors increases; false otherwise.

nextPrime(n)

Returns the next prime number larger than the magnitude of n.

primeFactors(n)

Returns an array of objects containing the properties factor and magnitude representing the prime factors of n and their magnitude.

Test

npm run test