Cody

# Problem 734. Ackermann's Function

Solution 1639417

Submitted on 7 Oct 2018
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
m=0; n=1; Ack = n+1; assert(isequal(ackermann(m,n),Ack))

2   Fail
m=0; n=1024; Ack = n+1; assert(isequal(ackermann(m,n),Ack))

Error using zeros Requested 204800x204800 (312.5GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in ackermann (line 3) A=zeros(200*m+200*n,200*n+200*m); Error in Test2 (line 4) assert(isequal(ackermann(m,n),Ack))

3   Fail
m=0; n=randi(1024) Ack = n+1; assert(isequal(ackermann(m,n),Ack))

n = 142

Error using zeros Out of memory. Type "help memory" for your options. Error in ackermann (line 3) A=zeros(200*m+200*n,200*n+200*m); Error in Test3 (line 4) assert(isequal(ackermann(m,n),Ack))

4   Fail
m=1; n=1024 Ack = n+2; assert(isequal(ackermann(m,n),Ack))

n = 1024

Error using zeros Requested 205000x205000 (313.1GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in ackermann (line 3) A=zeros(200*m+200*n,200*n+200*m); Error in Test4 (line 4) assert(isequal(ackermann(m,n),Ack))

5   Fail
m=1; n=randi(1024) Ack = n+2; assert(isequal(ackermann(m,n),Ack))

n = 791

Error using zeros Requested 158400x158400 (186.9GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in ackermann (line 3) A=zeros(200*m+200*n,200*n+200*m); Error in Test5 (line 4) assert(isequal(ackermann(m,n),Ack))

6   Pass
m=2; n=randi(128) Ack = 2*n+3; assert(isequal(ackermann(m,n),Ack))

n = 90

7   Pass
m=3; n=6; Ack = 509; assert(isequal(ackermann(m,n),Ack))

8   Pass
m=3; n=randi(6) Ack = 2^(n+3)-3; assert(isequal(ackermann(m,n),Ack))

n = 4

9   Pass
m=4; n=0; Ack = 13; assert(isequal(ackermann(m,n),Ack))

10   Fail
m=4; n=1; % Fails at RecursionLimit 1030; Create Special Ack = 65533; assert(isequal(ackermann(m,n),Ack))

Assertion failed.