Sunday, May 13, 2012

recursive function 예 (forward declaration 사용)

 local factorial  
 function factorial(n)  
      if (n == 1) then return 1  
      else  
           return factorial(n - 1) * n  
      end  
 end  
   
 print(factorial(5))  

No comments:

Post a Comment