开发者

what this function do please ? (java)

开发者 https://www.devze.com 2022-12-23 21:00 出处:网络
public static int ABC(int x, int y) { if(y==0) ret开发者_运维知识库urn(1); else return(x * ABC(x,y-1));
    public static int ABC(int x, int y)
{
    if(y==0)
        ret开发者_运维知识库urn(1);
    else
        return(x * ABC(x,y-1));
}

what this function do please ? factorial ?


The x is never changed and multiplied to the 1 exactly y times, as y is decremented in each recursive call until it is 0. So the function computes x^y in a recursive way.


Looks like x ^ y

0

精彩评论

暂无评论...
验证码 换一张
取 消