连分数算法
连分数算法 | |
---|---|
术语名称 | 连分数算法 |
英语名称 | continued fraction algorithm |
算法
对给定实数 [math]\displaystyle{ a }[/math] ,有
- 令 [math]\displaystyle{ i \leftarrow 0 }[/math] ,
- 令第 [math]\displaystyle{ i }[/math] 个部分商 [math]\displaystyle{ a_i = \lfloor a \rfloor }[/math] ,
- 计算 [math]\displaystyle{ a - a_i }[/math] ,如果为 0 终止循环
- 令第 [math]\displaystyle{ i+1 }[/math] 个完全商 [math]\displaystyle{ b_{i+1} = \frac{1}{a - a_i} }[/math]
- 令 [math]\displaystyle{ a\leftarrow b_{i+1}, i \leftarrow i + 1 }[/math] ,回到第 2 步。