ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 06 Nov 2013 04:41:54 +0100Continued fraction of pi by handhttps://ask.sagemath.org/question/10702/continued-fraction-of-pi-by-hand/Hello, I'm a newbie in Sage.
I tried to compute (sagenb.org) the continued fraction of pi by hand with the following commands
<pre><code>n=15
x=range(n+1);a=range(n)
x[0]=pi
for i in range(n):
a[i] = int(x[i])
x[i+1]=1/(x[i]-a[i])
print(a[i])
</code></pre>
the answer (14 terms) is correct, but then I get
<pre><code>Traceback (click to the left of this block for traceback)
...
ValueError: Calling floor() on infinity or NaN</code></pre>
Am I doing something wrong?
CheersMarco CaliariWed, 06 Nov 2013 04:41:54 +0100https://ask.sagemath.org/question/10702/