G
Guest
Ok, this is what i am tying to do:
I want to create a rutine that takes a value from a text box. Lets say for
example 5. and does the following 5*4*3*2*1 = 120
the rutine should be able to take any number and do the same:
if it is 9 then it should multiply: 9*8*7*6*5*4*3*2*1
if it is 3 then it should multiply: 3*2*1
I was working with this one but didnt get what i wanted:
Function Factorial(ByVal N As Integer) As Integer
If N <= 1 Then ' Reached end of recursive calls.
Return 1 ' N = 0 or 1, so climb back out of calls.
Else ' N > 1, so call Factorial again.
Return Factorial(N - 1) * N
End If
End Function
If someone has any suggestions,
Thanks,
I want to create a rutine that takes a value from a text box. Lets say for
example 5. and does the following 5*4*3*2*1 = 120
the rutine should be able to take any number and do the same:
if it is 9 then it should multiply: 9*8*7*6*5*4*3*2*1
if it is 3 then it should multiply: 3*2*1
I was working with this one but didnt get what i wanted:
Function Factorial(ByVal N As Integer) As Integer
If N <= 1 Then ' Reached end of recursive calls.
Return 1 ' N = 0 or 1, so climb back out of calls.
Else ' N > 1, so call Factorial again.
Return Factorial(N - 1) * N
End If
End Function
If someone has any suggestions,
Thanks,