[Numpy-discussion] Greater common divisor

Sebastian Haase seb.haase at gmail.com
Mon Jun 7 07:07:59 EDT 2010


googling for
greatest common divisor OR denominator numpy OR scipy OR python

I found this:
http://projects.scipy.org/numpy/browser/trunk/numpy/core/_internal.py?rev=8316
554	def _gcd(a, b):
555	    """Calculate the greatest common divisor of a and b"""
556	    while b:
557	        a, b = b, a%b
558	    return a

or this:
http://www.geekpedia.com/code120_Find-The-Greatest-Common-Divisor.html
def euclid(numA, numB):
   while numB != 0:
      numRem = numA % numB
      numA = numB
      numB = numRem
   return numA


HTH,
Sebastian Haase



On Mon, Jun 7, 2010 at 12:19 PM, Daniele Nicolodi <daniele at grinta.net> wrote:
> Hello. There is a method in numpy to compute the greater common divisor
> of the elements of an array? Searching through the documentation I
> didn't find it.
>
> Thanks. Cheers,
> --
> Daniele
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list