gcd or igcd denotes the gcd (greatest common divisor)
of several integers (for polynomials, see also 5.26.7).
gcd or igcd returns the GCD of integers.
Input :
Output :
Input :
Output :
Input :
Output :
We can also put as parameters two lists of same size (or a matrix with 2
rows), in this case gcd returns the greatest common divisor of
the elements with same index (or in the same column).
Input :
or :
Output :
An example
Find the greatest common divisor of 4n+1 and 5n+3 when n ∈ ℕ.
Input :
Then, input :
essai(n):={ local j,a,L; L:=NULL; for (j:=-n;j<n;j++) { a:=f(j); if (a!=1) { L:=L,[j,a]; } } return L; }
Then, input :
Output :
So we now have to prove that :
If n≠5+k*7 (for k ∈ ℤ), 4n+1 and 5n+3 are mutually prime,
and n=5+k*7 (for k ∈ ℤ), then the greatest common divisor of 4n+1
and 5n+3 is 7.