#PHP, 60+43+11 = 114 bytes ignore the line breaks; they are for readability only. function u($n,$m){return$m<2&$n<2?3**$n:u(u($n-1,$m),$m-1);} function g($x){return u(3,$x>1?g($x-1):4);} echo g(63); It is possible to integrate the second case into the first one: for `n=1`, `3^n` equals `3`. This will save a few bytes on - as far as I can see - all existing answers; saved two bytes on my **previous version, 62 bytes**(+43+11): function u($n,$m){return$m>1?$n>1?u(u($n-1,$m),$m-1):3:3**$n;} PHP´s left associativity of the ternary requires parentheses ... or a specific order of tests. This saved two bytes on the parenthesized expression. --- I bet there´s more golfing to the algorithm