Ackerman(m, n) = n + 1 si m = 0
Ackerman(m, n) = Ackerman(m - 1, 1) si m > 0 y n = 0
Ackerman(m, n) = Ackerman(m - 1, Ackerman(m, n - 1)) si m > 0 y n > 0
Con ello se tiene que Ackermann(1, 2) = 4 y Ackermann(3, 2) = 29
//
public static long ackerman (int n, int m) {
if (n == 0)
return ( m+1 );
else if ( m == 0 )
return ackerman ( n-1, 1);
else
return ackerman ( n-1, ackerman ( n, m-1 ));
good !!!
ResponderEliminarque es ackerman (5,3)
ResponderEliminar