Menampilkan Faktorial Suatu Bilangan

Partial Class Faktor
Inherits System.Web.UI.Page

Private Function Faktorial(ByVal Angka As Integer) As Integer
If Angka = 0 Or Angka = 1 Then
Return 1
Else
Return Angka * Faktorial(Angka - 1)
End If
End Function

Protected Sub BtFaktorial_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtFaktorial.Click
Dim hasil As Integer = 1
Dim Angka As Integer
Angka = CInt(Me.TbInputAngka.Text)
hasil = Faktorial(Angka)
Me.LbAngka.Text = CInt(Angka)
Me.LbFaktorial.Text = CStr(hasil)
End Sub

End Class

Program untuk Menampilkan Faktorial

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: