Cody

# Problem 734. Ackermann's Function

Solution 1559447

Submitted on 13 Jun 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   Pass
m=0; n=1024; Ack = n+1; assert(isequal(ackermann(m,n),Ack))

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

n = 967

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

n = 1024

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

n = 587

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

n = 43

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 = 2

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

upn = function_handle with value: @(n,x)(n>0)*up(upn(n-1,x))

Undefined function 'upn' for input arguments of type 'double'. Error in ackermann>@(n,x)(n>0)*up(upn(n-1,x)) Error in ackermann (line 14) vAck = upn(n+3,2)-3; Error in Test9 (line 4) 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))

upn = function_handle with value: @(n,x)(n>0)*up(upn(n-1,x))

Undefined function 'upn' for input arguments of type 'double'. Error in ackermann>@(n,x)(n>0)*up(upn(n-1,x)) Error in ackermann (line 14) vAck = upn(n+3,2)-3; Error in Test10 (line 4) assert(isequal(ackermann(m,n),Ack))