NZMATH  1.2.0
About: NZMATH is a Python based number theory oriented calculation system.
  Fossies Dox: NZMATH-1.2.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

nzmath.gcd Namespace Reference


def gcd (a, b)
def binarygcd (a, b)
def extgcd (x, y)
def gcd_of_list (integers)
def lcm (a, b)
def coprime (a, b)
def pairwise_coprime (int_list)

Detailed Description

funtions related to the greatest common divisor of integers.

Function Documentation

◆ binarygcd()

def nzmath.gcd.binarygcd (   a,
Return the greatest common divisor of 2 integers a and b
by binary gcd algorithm.

Definition at line 16 of file

◆ coprime()

def nzmath.gcd.coprime (   a,
Return True if a and b are coprime, False otherwise.

For Example:
>>> coprime(8, 5)
>>> coprime(-15, -27)

Definition at line 68 of file

References nzmath.gcd.gcd().

Referenced by nzmath.gcd.pairwise_coprime().

◆ extgcd()

def nzmath.gcd.extgcd (   x,
Return a tuple (u, v, d); they are the greatest common divisor d
of two integers x and y and u, v such that d = x * u + y * v.

Definition at line 25 of file

Referenced by nzmath.gcd.gcd_of_list(), and nzmath.finitefield.ExtendedFieldElement.inverse().

◆ gcd()

def nzmath.gcd.gcd (   a,

◆ gcd_of_list()

def nzmath.gcd.gcd_of_list (   integers)
Return a list [d, [c1, ..., cn]] for a list of integers [x1, ..., xn]
such that d = c1 * x1 + ... + cn * xn.

Definition at line 40 of file

References nzmath.gcd.extgcd(), and nzmath.bigrange.range().

◆ lcm()

def nzmath.gcd.lcm (   a,
Return the least common multiple of given 2 integers.
If both are zero, it raises an exception.

Definition at line 61 of file

References nzmath.gcd.gcd().

◆ pairwise_coprime()

def nzmath.gcd.pairwise_coprime (   int_list)
Return True if all integers in int_list are pairwise coprime,
False otherwise.

For example:
>>> pairwise_coprime([1, 2, 3])
>>> pairwise_coprime([1, 2, 3, 4])

Definition at line 81 of file

References nzmath.gcd.coprime().