Python code on continued fractions
<p>I'm trying to understand what is happening in the python code below. I take the square root of 2 and divide its decimals by 1. Doing this for 5 times keeps giving the same value but the 6th and 7th time I get different values.</p>

<p>Why does the output change at the 6th time when the input value is the same as in the previous 5 calculations?</p>

<pre><code>import math as M
frct = M.sqrt(2)

# 1
frct = 1 / (frct - int(frct))
print frct # 2.41421356237

# 2
frct = 1 / (frct - int(frct))
print frct # 2.41421356237

# 3
frct = 1 / (frct - int(frct))
print frct # 2.41421356237

# 4
frct = 1 / (frct - int(frct))
print frct # 2.41421356237

# 5
frct = 1 / (frct - int(frct))
print frct # 2.41421356237

# 6
frct = 1 / (frct - int(frct))
print frct # 2.41421356238

# 7
frct = 1 / (frct - int(frct))
print frct # 2.41421356235
</code></pre>
