Kamis, 31 Juli 2025

VB HitungJmlhFaktorial

 Module HitungJmlhFaktorial

    'Buka HitungJmlhFaktorial.vbproj

    Sub Main()

        Dim a, b, c, x, fact As Integer

        a = 0 : b = 0 : c = 1 : fact = 1

        x = InputBox("Masuk jumlah utk hitung: ")

        For a = 1 To x

            fact = 1 : c = a

            Do While (c >= 1)

                fact = fact * c : c = c - 1

            Loop

            b = b + fact

        Next a

        Debug.Print("Jumlah Factorial " & (a - 1) & "! = " & b)

    End Sub


End Module


Tidak ada komentar: