On Tue, 04 Mar 2014 14:46:25 +1100, Chris Angelico wrote: > That's neat, didn't know that. Is there an efficient way to figure out, > for any integer N, what its sqrt's CF sequence is? And what about the > square roots of non-integers - can you represent √π that way? I suspect, > though I can't prove, that there will be numbers that can't be > represented even with an infinite series - or at least numbers whose > series can't be easily calculated.
Every rational number can be written as a continued fraction with a finite number of terms[1]. Every irrational number can be written as a continued fraction with an infinite number of terms, just as every irrational number can be written as a decimal number with an infinite number of digits. Most of them (to be precise: an uncountably infinite number of them) will have no simple or obvious pattern. [1] To be pedantic, written as *two* continued fractions, one ending with the term 1, and one with one less term which isn't 1. That is: [a; b, c, d, ..., z, 1] == [a; b, c, d, ..., z+1] Any *finite* CF ending with one can be simplified to use one fewer term. Infinite CFs of course don't have a last term. -- Steven -- https://mail.python.org/mailman/listinfo/python-list