marxen.c is an entry by Heiner Marxen for the Bignum Bakeoff contest, whose objective is to write a C program (in 512 characters or less) that generates the largest possible output. It came in second place in the competition, behind Loader's number.
The program uses a variant of the Goodstein sequence. Its output is lower bounded by \(f_{\omega^{\omega}}(2\uparrow\uparrow 500)\) and upper bounded by \(f_{\varepsilon_{0}+{\omega^3}}(1,000,000)\) 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(z)[]
- If z = 0, then H(z)=0.
- Otherwise, H(z)=z%2 + 2H(z/4)
I(f,e,r)[]
- If f = 0, then I(f,e,r)=r.
- 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)
This is the number produced by the program, and thus the number submitted to the Bignum Bakeoff.
Sources[]
See also[]
Large numbers in computers
Main article: Numbers in computer arithmetic
127 · 128 · 256 · 32767 · 32768 · 65536 · 2147483647 · 4294967296 · 9007199254740991 · 9223372036854775807 · FRACTRAN catalogue numbersBignum Bakeoff contestants: pete-3.c · pete-9.c · pete-8.c · harper.c · ioannis.c · chan-2.c · chan-3.c · pete-4.c · chan.c · pete-5.c · pete-6.c · pete-7.c · marxen.c · loader.c
Channel systems: lossy channel system · priority channel system
Concepts: Recursion