Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

primeval

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

primeval

A tiny (77B) utility to check if a value is a prime number

Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

primeval Build Status

A tiny (77B) utility to check if a value is a prime number

Makes use of a very neat trick which proves that squaring any prime number, excluding the "sub primes", is always 1 more than a multiple of 24 🤯 — watch the video!

All credit goes to Matt Parker and Numberphile

This module exposes three module definitions:

  • ES Module: dist/primeval.mjs
  • CommonJS: dist/primeval.js
  • UMD: dist/primeval.min.js

Install

$ npm install --save primeval

Usage

import primeval from 'primeval';

primeval(2);   //=> true
primeval(3);   //=> true
primeval(17);  //=> true
primeval(29);  //=> true
primeval(25);  //=> false
primeval(512); //=> false
primeval(12);  //=> false
primeval(1);   //=> false

primeval("foobar");   //=> false
primeval(100.1231);   //=> false
primeval(null);       //=> false

API

primeval(num)

Returns: Boolean

num

Type: Number

The number that you want to check.

Note: Any non-Number type will always return a false output.

License

MIT © Luke Edwards

Keywords

prime

FAQs

Package last updated on 16 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts