gcd or igcd denotes the gcd (greatest common divisor)
of several integers (for polynomials see also 2.25.7).
gcd or igcd returns the GCD of all integers.
Input :
Output :
Input :
Output :
Input :
Output :
We can also put as parameters two lists of same size (or a matrix with 2 lines), in this case gcd returns the greatest common divisor of the elements with same index (or of 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 have now to prove that :
if n!=5+k*7 (for k ∈ ℤ), 4n+1 and 5n+3 are mutually prime,
and
if n=5+k*7 (for k ∈ ℤ), the greatest common divisor of 4n+1
and 5n+3 is 7.