求无理平方根连分数表示法的循环节的程序
代码如下:Private Sub Command1_Click()
Dim d, a0, r
d = Val(Text1)
a0 = Int(Sqr(d))
a1 = a0
r = Sqr(d)
s = a0
Do Until a1 = 2 * a0
s1 = s1 + 1
r = 1 / (r - a1)
a1 = Int(r)
s = s & "/" & a1
Loop
Text2 = s
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
End Sub
举例:输入22,输出:4/1/2/4/2/1/8
输入31,输出:5/1/1/3/5/3/1/1/10
输入:45,输出:6/1/2/2/2/1/12
输入:97,输出:9/1/5/1/1/1/1/1/1/5/1/18