Namespaces

Types

Type IntegerTheory

Namespace MathNet.Numerics.NumberTheory

Number theory utility functions for integers.

Methods

Public static methods

int CeilingToPowerOfTwo(this int number)

Find the closest perfect power of two that is larger or equal to the provided 32 bit integer.
Parameters
return int A power of two.
int number The number of which to find the closest upper power of two.

long CeilingToPowerOfTwo(this long number)

Find the closest perfect power of two that is larger or equal to the provided 64 bit integer.
Parameters
return long A power of two.
long number The number of which to find the closest upper power of two.

long ExtendedGreatestCommonDivisor(long a, long b, Int64& x, Int64& y)

Parameters
return long
long a
long b
Int64& x
Int64& y

long GreatestCommonDivisor(long a, long b)

Returns the greatest common divisor (gcd) of two integers using Euclid's algorithm.
Parameters
return long Greatest common divisor gcd(a,b)
long a First Integer: a.
long b Second Integer: b.

long GreatestCommonDivisor(IList<long> integers)

Returns the greatest common divisor (gcd) of a set of integers using Euclid's algorithm.
Parameters
return long Greatest common divisor gcd(list of integers)
IList<long> integers List of Integers.

long GreatestCommonDivisor(Int64[] integers)

Returns the greatest common divisor (gcd) of a set of integers using Euclid's algorithm.
Parameters
return long Greatest common divisor gcd(list of integers)
Int64[] integers List of Integers.

bool IsEven(this int number)

Find out whether the provided 32 bit integer is an even number.
Parameters
return bool True if and only if it is an even number.
int number The number to very whether it's even.

bool IsEven(this long number)

Find out whether the provided 64 bit integer is an even number.
Parameters
return bool True if and only if it is an even number.
long number The number to very whether it's even.

bool IsOdd(this long number)

Find out whether the provided 64 bit integer is an odd number.
Parameters
return bool True if and only if it is an odd number.
long number The number to very whether it's odd.

bool IsOdd(this int number)

Find out whether the provided 32 bit integer is an odd number.
Parameters
return bool True if and only if it is an odd number.
int number The number to very whether it's odd.

bool IsPerfectSquare(int number)

Find out whether the provided 32 bit integer is a perfect square, i.e. a square of an integer.
Parameters
return bool True if and only if it is a perfect square.
int number The number to very whether it's a perfect square.

bool IsPerfectSquare(long number)

Find out whether the provided 64 bit integer is a perfect square, i.e. a square of an integer.
Parameters
return bool True if and only if it is a perfect square.
long number The number to very whether it's a perfect square.

bool IsPowerOfTwo(this long number)

Find out whether the provided 64 bit integer is a perfect power of two.
Parameters
return bool True if and only if it is a power of two.
long number The number to very whether it's a power of two.

bool IsPowerOfTwo(this int number)

Find out whether the provided 32 bit integer is a perfect power of two.
Parameters
return bool True if and only if it is a power of two.
int number The number to very whether it's a power of two.

long LeastCommonMultiple(Int64[] integers)

Returns the least common multiple (lcm) of a set of integers using Euclid's algorithm.
Parameters
return long Least common multiple lcm(list of integers)
Int64[] integers List of Integers.

long LeastCommonMultiple(long a, long b)

Returns the least common multiple (lcm) of two integers using Euclid's algorithm.
Parameters
return long Least common multiple lcm(a,b)
long a First Integer: a.
long b Second Integer: b.

long LeastCommonMultiple(IList<long> integers)

Returns the least common multiple (lcm) of a set of integers using Euclid's algorithm.
Parameters
return long Least common multiple lcm(list of integers)
IList<long> integers List of Integers.

int PowerOfTwo(this int exponent)

Raises 2 to the provided integer exponent (0 <= exponent < 31).
Parameters
return int 2 ^ exponent.
int exponent The exponent to raise 2 up to.

long PowerOfTwo(this long exponent)

Raises 2 to the provided integer exponent (0 <= exponent < 63).
Parameters
return long 2 ^ exponent.
long exponent The exponent to raise 2 up to.