How about adding rational fraction to Python?

Mensanator mensanator at aol.com
Sun Feb 24 18:58:07 EST 2008


On Feb 24, 4:50�pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Sun, 24 Feb 2008 11:09:32 -0800, Lie wrote:
> > I decided to keep the num/den limit low (10) because higher values might
> > obscure the fact that it do have limits.
>
> You do realise that by putting limits on the denominator, you guarantee
> that the sum of the fractions also has a limit on the denominator? In
> other words, your "test" is useless.
>
> With denominators limited to 1 through 9 inclusive, the sum will have a
> denominator of 2*3*5*7 = 210.

Th limit will be 2*2*2*3*3*5*7. As MD said, "equivalently
the product over all primes p <= n of the highest power
of p not exceeding n".


> But that limit is a product (literally and
> figuratively) of your artificial limit on the denominator. Add a fraction
> with denominator 11, and the sum now has a denominator of 2310; add
> another fraction n/13 and the sum goes to m/30030; and so on.
>
> --
> Steven




More information about the Python-list mailing list