Exemples d’utilisation ici: http://irem.univ-reunion.fr/spip.php?article970
divisors(n) yields the list of the divisors of an integer n;
cd(a,b) (“common divisors”) yields the lists of the common divisors of a and b;
gcd(a,b) yields the greatest of the common divisors
and isPrime(n) is a test for the primality of the integer n.
def inter(l1,l2): return [x for x in l1 if x in l2] def divisors(n): return [d for d in range(1,n+1) if n%d==0] def isPrime(n): return len(divisors(n))==2 def cd(a,b): return inter(divisors(a),divisors(b)) def gcd(a,b): return max(cd(a,b))