Link Search Menu Expand Document

Number Theory

number-theory.ts#L116

eulerPhi (x: number): number

Computes Euler’s totient function (phi) for a given natural number x.

Name Type Default Description
x number    
number-theory.ts#L11

gcd (numbers: Array<number>): number

Calculates the greatest common divisor of multiple numbers.

Name Type Default Description
numbers Array<number>    
number-theory.ts#L83

generatePrime (d: number): number

Generates a random prime number with d digits, where 2 <= d <= 16.

Name Type Default Description
d number    
number-theory.ts#L97

goldbach (x: number): undefined|Array<number>

Tries to write a number x as the sum of two primes.

Name Type Default Description
x number    
number-theory.ts#L31

isPrime (n: number): boolean

Checks if a number n is prime.

Name Type Default Description
n number    
number-theory.ts#L23

lcm (numbers: Array<number>): number

Calculates the lowest common multiple of multiple numbers.

Name Type Default Description
numbers Array<number>    
number-theory.ts#L67

listPrimes (n: number): Array<number>

Lists all prime numbers between 0 and n.

Name Type Default Description
n number 100  
number-theory.ts#L47

primeFactorisation (n: number): Array<number>

Finds the prime factorisation of a number n.

Name Type Default Description
n number    
number-theory.ts#L62

primeFactors (n: number): Array<number>

Finds all prime factors of a number n.

Name Type Default Description
n number    

Copyright © 2021 Mathigon.org