1

不久前我找到了这个问题的答案,但后来忘记了。经过几个小时的再次搜索,我似乎找不到它。我有这个递归方法:

public static int f(int x, int y) {
    if (x==0) return 1+y;
    if (y==0) return f(x-1,1);
    return f(x-1, f(x,y-1));
}

我知道确定将返回什么的公式是:

什么时候x = 0,公式是y + 1
什么时候x = 1,公式是y + 2
什么时候x = 2,公式是2y + 3

除此之外我什么都不知道。

我的问题是这个递归算法叫什么,有没有办法为xand的任何值确定一个完全简化的函数y?提前致谢!

4

1 回答 1

4

That looks like the Ackermann function: http://en.wikipedia.org/wiki/Ackermann_function

According to wikipedia this is a multiply recursive problem so I think there is no non-recursive way to represent it.

于 2013-05-18T22:02:26.727 回答