User blog:Sait2000/Base-k Arrow Notation

python code def hyper(a, b, c): # a^^...(c ^s)...^b if c<1: return a*b if b<2: return a return hyper(a, hyper(a, b-1, c), c-1)

def R(n, k1, k2): # replace k1 to k2 in base-k1 arrow notation of n if a<k1*k1: return a   # alternative: return a//k1*k2+a%k1 b=2, c=1 while hyper(k1, b, c+1) <= a: c += 1 while hyper(k1, b+1, c) <= a: b += 1 return hyper(k2, b, R(c, k1, k2)) + R(n - hyper(k1, b, c), k1, k2)

def G(n, b=3): # Goodstein function using base-k arrow notation if n < 1: return b  return G(R(n, b, b+1)-1, b+1)