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

## Functions

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.
```

## ◆ binarygcd()

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

Definition at line 16 of file gcd.py.

## ◆ coprime()

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

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

Definition at line 68 of file gcd.py.

References nzmath.gcd.gcd().

Referenced by nzmath.gcd.pairwise_coprime().

## ◆ extgcd()

 def nzmath.gcd.extgcd ( x, y )
```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 gcd.py.

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

## ◆ gcd()

 def nzmath.gcd.gcd ( a, b )
```Return the greatest common divisor of 2 integers a and b.
```

Definition at line 7 of file gcd.py.

## ◆ 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 gcd.py.

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

## ◆ lcm()

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

Definition at line 61 of file gcd.py.

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])
True
>>> pairwise_coprime([1, 2, 3, 4])
False
>>>
```

Definition at line 81 of file gcd.py.

References nzmath.gcd.coprime().