java - Unknown Recursive Algorithm -


i have found answer problem while ago have since forgotten it. after hours of searching again, cannot seem find it. have recursive method:

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)); } 

i know formula determining return is:

when x = 0, formula y + 1
when x = 1, formula y + 2
when x = 2, formula 2y + 3.

i don't know beyond that.

my question(s) recursive algorithm called , there way determine simplified function value of x , y? in advance!

that looks ackermann function: http://en.wikipedia.org/wiki/ackermann_function

according wikipedia multiply recursive problem think there no non-recursive way represent it.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -