# prime-functions

1.2.2 • Public • Published

# Prime Functions (Useful Prime Numbers Functions)

Primes are of the utmost importance to number theorists because they are the building blocks of whole numbers, and important to the world because their odd mathematical properties make them perfect for our current uses. On that matter we've built a library to create and find prime numbers

### Features

• Basic prime number generators
• Primes' indexes
• High performance
• Some special prime arrays
• Relations with normal integers

## Playground

You can play with the functions on prime-functions.truncgil.com

## Installation

npm install prime-functions

## Usage

You can simply use the prime-functions on the client side:

## Functions

#### isPrime(number)

Return if a number is Prime Number

#### nthPrime(order)

Get nth prime

Get index of prime number

Index starts from 0

#### primeBiggerThan(number)

Checks if a prime is a Mersenne Prime

#### nthMersennePrime(order)

Get nth Mersenne Prime

#### nthMersennePrimeExponents(order)

Get nth Mersenne Prime's exponents

#### isPrimeOrDivisors(number)

If the number is prime it returns true, otherwise it returns prime divisors

helper function

helper function

helper function

helper function

#### printExecutionTime()

helper function That should be bottom of the script

helper function

helper function

helper function

helper function

helper function

#### firstNDigits(number, n, returnAsInteger=true)

helper function

Returns number first n digits

#### lastNDigits(number, n, returnAsInteger=true)

helper function

Returns number last n digits

#### isEmirp(number)

returns if the given number is emirp.

#### nthEmirp(number)

returns nth emirp. 1 is the 11

#### hasTwinPrime(number, returnItsTwin=true)

check if the prime has a twin

helper

#### wilsonsTheorem(n, returnWithExplanation=true)

The Wilson's Theorem.

n+1 should be prime number if and only if n! mod(n+1) = n.

returnWithExplanation is the conditions and explanation of Wilson's Theorem.

#### phi(n)

Euler's phi and also known as totient function.

Function can be used as both phi and totient

#### isTruncatable(number)

Check if the given number is Truncatable Prime

#### truncatableValues(number)

Returns number's Truncatable values

#### nthTruncatablePrime(n)

Finds the nth Truncatable Prime

#### isPanditalPrime(n)

Checks if the given number is Pandigital Prime

## Package Sidebar

### Install

npm i prime-functions

### Repository

github.com/sundowatch/prime-functions

### Homepage

github.com/sundowatch/prime-functions

5

1.2.2

MIT

32.9 kB

3