1 # ----------------------------------------------------------------------
2 # The Computer Language Shootout
3 # http://shootout.alioth.debian.org/
5 # Code based on / inspired by existing, relevant Shootout submissions
7 # Contributed by Anthony Borla
8 # Optimized by Jesse Millikan
9 # ----------------------------------------------------------------------
17 ack(m - 1, ack(m, n - 1))
22 # ---------------------------------
26 fib(n - 2) + fib(n - 1)
32 # ---------------------------------
36 tak(tak(x - 1.0, y, z), tak(y - 1.0, z, x), tak(z - 1.0, x, y))
41 # ---------------------------------
43 n = (ARGV.shift || 1).to_i
45 printf("Ack(3,%d): %d\n", n, ack(3, n));
46 printf("Fib(%.1f): %.1f\n", 27.0 + n, fib(27.0 + n));
49 printf("Tak(%d,%d,%d): %d\n", n * 3, n * 2, n, tak(n * 3, n * 2, n));
51 printf("Fib(3): %d\n", fib(3));
52 printf("Tak(3.0,2.0,1.0): %.1f\n", tak(3.0, 2.0, 1.0));