Working with the set of real numbers

Chris Angelico rosuav at
Tue Mar 4 20:58:23 CET 2014

On Wed, Mar 5, 2014 at 6:49 AM, Marko Rauhamaa <marko at> wrote:
> Chris Angelico <rosuav at>:
>> As far as I know, there's no simple way, in constant space and/or
>> time, to progressively yield more digits of a number's square root,
>> working in decimal.
> I don't know why the constant space/time requirement is crucial. Anyway,
> producing more digits simple: <URL:>.
> I believe producing the nth digit is O(n) in time and space.

The reason for striving for constant space/time is because the obvious
method (cut-and-try) is already O(n) for the nth digit, which means
it's quadratic on the number of digits desired. That gets pretty
nasty. So what I was asking was: By representing values as continued
fractions rather than as decimal digits, are you able to perform a
straight-forward transformation that produces the square root, in
constant time (which means linear in the length)? And I guess the
answer's no. CF representation doesn't have the advantage I was
wondering about.


More information about the Python-list mailing list