marxen.c est une participation de Heiner Marxen au concours Bignum Bakeoff, dont l'objectif est d'écrire un programme C (en 512 caractères ou moins) qui génère la plus grande sortie possible. Il est arrivé en deuxième position du concours, derrière le nombre de Loader.
The program uses a variant of the Goodstein sequence. Its output is lower bounded by and upper bounded by in the fast-growing hierarchy.[1]
Code[]
typedef int J; J P(J x,J y) { return x+y ? x%2 + y%2*2 + P(x/2,y/2)*4 : 0 ;} J H(J z) { return z ? z%2 + 2*H(z/4) : 0 ;} J I(J f,J e,J r){ return f ? P(P(f,e),r) : r ;} J M(J x,J e) { return x ? I(x%2, M(e,0), M(x/2, e+1)) : 0 ;} J D(J,J); J E(J f,J e,J r,J b) { return e ? E(1, D(e,b), I(b-1, D(e,b), I(f-1,e,r)), b) : I(f-1,e,r) ; } J D(J x,J b) { return x ? E( H(H(x)), H(H(x)/2), H(x/2), b) : 0 ;} J F(J x,J b) { return x ? F(D(x,b+1),b+1) : b ;} J G(J x) { return F(M(x,9), 9) ;} J f(J n,J x) { return n ? f(n-1, G(x ? f(n,x-1) : n)) : G(x) ;} J g(J x) { return f(x,x) ;} J h(J n,J x) { return n ? h(n-1, g(x ? h(n,x-1) : n)) : g(x) ;} J main(void) { return h(g(9),9) ;}
Functions defined in Marxen.c[]
In the following, the operator symbol / denotes the integral division and a % b is equivalent to a (mod b).
P(x,y)[]
- If x+y = 0, then P(x,y)=0.
- Otherwise, P(x,y)=x%2 + y%2*2 + 4P(x/2,y/2).
H(x)[]
- If x = 0, then H(x)=0.
- Otherwise, H(x)=z%2 + 2H(z/4)
I(f,e,r)[]
- If f = 0, then I(f,e,r)=0.
- Otherwise, I(f,e,r)=P(P(f,e),r)
M(x,e)[]
- If x = 0, then M(x,e)=0.
- Otherwise, M(x,e)=I(x%2, M(e,0), M(x/2,e+1))
D(x,b)[]
- If x = 0, then D(x,b)=0.
- Otherwise, D(x,b)=E(H(H(x)), H(H(x)/2), H(x/2), b)
E(f,e,r,b)[]
- If e = 0, then E(f,e,r,b)=I(f-1,e,r)
- Otherwise, E(f,e,r,b)=E(1, D(e,b), I(b-1, D(e,b), I(f-1,e,r)), b)
F(x,b)[]
- If x = 0, then F(x,b)=b.
- Otherwise, F(x,b)=F(D(x,b+1),b+1)
G(x)[]
G(x)=F(M(x,9),9)
f(n,x)[]
- If n = 0, then f(n,x)=G(x).
- Else if x = 0, then f(n,x)=f(n-1,G(n))
- Otherwise, f(n,x)=f(n-1,G(f(n,x-1)))
g(x)[]
g(x)=f(x,x)
h(n,x)[]
- If n = 0, then h(n,x)=g(x).
- Else if x = 0, then h(n,x)=h(n-1,g(n))
- Otherwise, h(n,x)=h(n-1,g(h(n,x-1)))
main()[]
main()=h(g(9),9)