Number Theory

eulerPhi (x: number): number

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

Name Type Default Description
x number    

gcd (numbers: Array<number>): number

Calculates the greatest common divisor of multiple numbers.

Name Type Default Description
numbers Array<number>    

generatePrime (d: number): number

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

Name Type Default Description
d number    

goldbach (x: number): [number, number]

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

Name Type Default Description
x number    

isPrime (n: number): boolean

Checks if a number n is prime.

Name Type Default Description
n number    

lcm (numbers: Array<number>): number

Calculates the lowest common multiple of multiple numbers.

Name Type Default Description
numbers Array<number>    

listPrimes (n: number): Array<number>

Lists all prime numbers between 0 and n.

Name Type Default Description
n number 100  

primeFactorisation (n: number): Array<number>

Finds the prime factorisation of a number n.

Name Type Default Description
n number    

primeFactors (n: number): Array<number>

Finds all prime factors of a number n.

Name Type Default Description
n number    

Copyright © 2024 Mathigon.org