On Thu, Jul 29, 2010 at 10:16 PM, James Mills <prolo...@shortcircuit.net.au> wrote: > On Fri, Jul 30, 2010 at 12:10 PM, James Mills > <prolo...@shortcircuit.net.au> wrote: >> def gcd(a, b): >> while b != 0: >> (a, b) = (b, a%b) >> return a
That was pretty short, and sweet. > > Here's another solution that uses a generator called factors to > generate a list of factors for any given value. The gcd function > then uses sets and intersection and the max function to find > the greatest common factor/divisor > > http://codepad.org/VJIRyvI8 > > cheers > James > > -- > -- James Mills > -- > -- "Problems are solved by method" > _______________________________________________ > Tutor maillist - tu...@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor