The case of the call stack calls the process of recursive function

In order to deepen the understanding of the recursive function calls in the process, specifically in this Demo program VS2008 C # console program implements the factorial calculation function, the case of recursive function calls for viewing the stack from the calling procedure.

Source as follows:

the using the System;
 the using the System.Collections.Generic;
 the using the System.Linq;
 the using the System.Text; 

namespace RecursiveTset 
{ 
    class Program 
    { 
        // definition of factorial: n = n * (n- 1) !, particularly, 1 =!! ! 1; 0 = 1
         // achieve factorial: recursive call mode. The main test and observe the function call stack recursive process! 
        public  static  int JiechengFun ( int NUM) 
        { 
            int Result = . 1 ;
             IF (NUM == 0 ) 
                Result = . 1 ;
             IF (NUM> =1)
                result = num * JiechengFun(num - 1);
            return result;
        }

        static void Main(string[] args)
        {
            int res = Program.JiechengFun(4);
            System.Console.WriteLine(res);
        }
    }
}

Case recursive function call stack in the process of calling shots are as follows:

Download Source: https://pan.baidu.com/s/18SHyws1vX2a-fvbT-nQUtw

Guess you like

Origin www.cnblogs.com/rainbow70626/p/11847865.html