Decimals -> Fraction strings, my solution
Scott
sbarron at ansic.net
Tue May 16 19:39:04 EDT 2000
Hi,
Oh yes this is much much better. I realized my way was terribly ineffici
ent when doing fractions like 17/64. Your method speeds it up immensely.
Thanks!
Scott
On 16-May-00 François Pinard wrote:
> kain at cableadmin.com (Scott) writes:
>
>> def gcd (numer, denom):
>> """Return the greatest common denominator of two numbers"""
>> if denom % numer == 0:
>> return numer
>
>> p1 = plist (numer)
>> p2 = plist (denom)
>> p1.reverse ()
>> for x in p1:
>> if x in p2:
>> return x
>
> Hi, people. I prefer the following definition for GCD:
>
> def gcd(a, b):
> while a:
> a, b = b % a, a
> return b
>
> --
> François Pinard http://www.iro.umontreal.ca/~pinard
----------------------------------
E-Mail: Scott <sbarron at ansic.net>
Date: 16-May-00
Time: 19:35:26
This message was sent by XFMail
----------------------------------
More information about the Python-list
mailing list