VB中一个数列,其前二项分别为1、2,从第三项开始,每项为其相邻的前二项之和的1/3.Public Class Form1Public Function fact(ByVal n As Integer) As DoubleDim i As IntegerDo Until fact < 0.0001For i = 1 To 2fact = nNextFor i = 3 T
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 13:38:24
VB中一个数列,其前二项分别为1、2,从第三项开始,每项为其相邻的前二项之和的1/3.Public Class Form1Public Function fact(ByVal n As Integer) As DoubleDim i As IntegerDo Until fact < 0.0001For i = 1 To 2fact = nNextFor i = 3 T
VB中一个数列,其前二项分别为1、2,从第三项开始,每项为其相邻的前二项之和的1/3.
Public Class Form1
Public Function fact(ByVal n As Integer) As Double
Dim i As Integer
Do Until fact < 0.0001
For i = 1 To 2
fact = n
Next
For i = 3 To n
fact = (fact(n - 2) + fact(n - 1)) / 2
Next
Loop
Label1.Text = n
End Function
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
Dim b As Integer
fact(b)
End Sub
这里哪里出错了?为何输出是0?
有一个数列,其前二项分别为1、2,从第三项开始,每项均为其相邻的前二项之和的1/3.判断该数列从第几项开始小于0.0001.
VB中一个数列,其前二项分别为1、2,从第三项开始,每项为其相邻的前二项之和的1/3.Public Class Form1Public Function fact(ByVal n As Integer) As DoubleDim i As IntegerDo Until fact < 0.0001For i = 1 To 2fact = nNextFor i = 3 T
老实说看了半天,看不太懂这函数
Public Function fact(ByVal n As Integer) As Double
dim Count as integer
Count=2
dim A as double,B as Double
dim C as Double
do until false
C=(A+B)\3
if C