Extrapolation proses with rekursi
06/11/2009 11:581. Design form and control program like this
2. double click on the rekursi Fibonasi botton and write listing procedure like below
Private Sub Command1_Click()
Dim jml As Integer
Dim a As Integer
Cls
jml = InputBox("Banyaknya data:")
Print "cetak " & jml & "Bilangan Fibonanci : ";
For a = 1 To jml
Print FIBO(a)
Next a
End Sub
3. make function with the name FIBO where inside its function wrote listing rekursi proses to counting fibonansi
Function FIBO(N As Integer) As Integer
If (N = 1) Or (N = 2) Then
FIBO = 1
Else
FIBO = FIBO(N - 1) + FIBO(N - 2)
End If
End Function
4. double click on the Rekursi faktorial botton and make procedure listing like this below
Private Sub Command2_Click()
Dim x As Integer
Cls
x = InputBox("banyaknya data:")
Print "faktorial dari bilangan " & x & ":" & faktor(x)
End Sub
5. make fuction with the name faktor where has rekursi proses in it
Function faktor(p As Integer) As Integer
If (p = 0) Then
faktor = 1
Else
faktor = p * faktor(p - 1)
End If
End Function
6. make procedure keluar with listing like below
Private Sub Command3_Click()
Unload Me
End Sub
7. Finally the result is
Tags:
———
BackTopic: Extrapolation proses with rekursi
No comments found.