How to understand the recursive call to itself

Total Post:68

Points:476
C# 
C#
 1744  View(s)
Ratings:
Rate this:

Hi all,

   such as:

Public Function Factorial(N As Integer) As Integer
    If N <= 1 Then
        Factorial = 1
    Else
        Factorial = Factorial(N - 1) * N
    End If
End Function
Sub res()
   Debug.Print Factorial(4)
End Sub

Its principle is to perform what,why the output is 24.

thanks!

  1. Post:40

    Points:280
    Re: How to understand the recursive call to itself

    Hi Aken,

    This is not a class room where you will get the code explained.

    Here, you can discuss your problem you are getting in your project or if you are stuck somewhere in your code. By this way experts here stop looking at your problem and you won't get your problem solved.

    So, please ask only relavent questions.

    By the way, the above code is calculating the factorial of 4.

    i.e. 4*3*2*1

    Google for detailed information about Recursion.

    Hope you will understand and won't repeat your mistakes again.

    Thanks

  1. Post:68

    Points:476
    Re: How to understand the recursive call to itself

    Hi Haider,

         sorry,i know,thanks for your help.

Answer