xen-dev-utils
Version:
Utility functions used by the Scale Workshop ecosystem
43 lines (42 loc) • 1.56 kB
TypeScript
/**
* Prime numbers up to 7919.
*/
export declare const PRIMES: number[];
/**
* Logarithms of prime numbers up to ln(7919).
*/
export declare const LOG_PRIMES: number[];
/**
* Prime number harmonics in additive representation measured in cents up to harmonic 7919 ≈ 15541.3 cents.
*/
export declare const PRIME_CENTS: number[];
/**
* BigInt representation of the primes.
*/
export declare const BIG_INT_PRIMES: bigint[];
/**
* Check a number for primality.
* @param n Number to check.
* @returns True if the number is prime, false otherwise.
*/
export declare function isPrime(n: number): boolean;
/**
* Obtain the nth odd prime.
* @param n 1-based ordinal of the nth odd prime, or zero to obtain prime two.
* @returns The nth odd prime number or `2` if `n === 0`.
*/
export declare function nthPrime(n: number): number;
/**
* Generate an array of prime numbers.
* @param start Smallest prime number to include (or the next smallest prime).
* @param end Largest prime number to include (or the previous largest prime).
* @returns An array of primes p in ascending order such that start <= p <= end.
*/
export declare function primes(start: number, end?: number): number[];
/**
* Obtain a range of primes starting at the given ordinal. Prime 2 has ordinal 0.
* @param start 1-based ordinal of the nth odd prime to start from, or zero to include prime two.
* @param end Range end. `end - start` elements are returned.
* @returns The primes in the range.
*/
export declare function primeRange(start: number, end?: number): number[];