Funciones de sumatorias y productos

Función para sumar N números enteros

Function Sumatoria(n As Integer) As Double
Dim i As Integer
Dim temporal As Double

    temporal = 0
    For i = 1 To n
        temporal = temporal + i
    Next i
    
    Sumatoria = temporal
End Function



Función para multiplicar N números enteros

Function MiProducto(n As Integer) As Double
Dim i As Integer
Dim temporal As Double

    temporal = 1
    For i = 1 To n
        temporal = temporal * i
    Next i
    
    MiProducto = temporal
End Function