lancidie

一 lua

 

function Fact(n)
    
if(n < 0then
        
return 0
    
end
    
    
if(n == 0then
        
return 1
    
else
        
return n * Fact(n-1)
    
end
end

 

二 C++

 

int Fact(int n)
{
    
if (n < 0)
    {
        
return 0;
    }

    
if (n == 0)
    {
        
return 1;
    }
    
else
    {
        
return n * Fact(n-1);
    }
}

 

 

分类:

技术点:

相关文章: