Factorial N with recursion


Is it possible to make a simple factorial recursion for n, but i want a main to call a sub (like a function).

I do not want to do it in a simple Do While or Lambda function, i want a main to call a function.

In vb.net it wil be:

Sub Main()
Dim n As Integer = 5
End Sub

Function factorial(ByVal n As Integer) As Integer
    If n <= 1 Then
        factorial = 1
        factorial = n * factorial(n - 1)
    End If
End Function

Please no While or Lambda! recursive if possible.

Thank you,

Proof of concept. You can use recursive delegate inside “Invoke Code activity”.
I try to do similar with Assign activity but no luck. It seems to me that Assign has more limitations.
For example some complex Linq expressions doesn’t work in Assign, but work in “Invoke Code Activity”.

But most annoying thing in Invoke code are disabled type interference and innability to use any assembly shortcut and of course lack of any code reusability.

Dim app as Microsoft.Office.Interop.Excel.Application is very ugly way to declare variable. And code bloated with this very quickly.

1 Like