Blogroll

Jumat, 02 Juni 2017

Membuat program console application untuk menghitung faktorial dengan pengulangan. Diketahui faktorial sebagai berikut.

3! = 3 x 2 x 1 = 6
4! = 4 x 3 x 2 x 1 = 24

Rumusnya adalah :

Sub main()
        Dim total As String
        Dim tambah, n, i As Integer
        total = ""
        tambah = 1
        Console.Write("Faktorial    : ")
        n = (Console.ReadLine)
        For i = n To 1 Step -1
            tambah = tambah * i
            If i = 1 Then
                total += CStr(i) & " = "
            Else
                total += CStr(i) & " x "
            End If
        Next i
        total += CStr(tambah)
        Console.WriteLine(total & "")

        Console.ReadKey()
    End Sub

Silahkan copy rumus diatas. Terima Kasih atas kunjungannya !!