1 // The Computer Language Shootout 2 // http://shootout.alioth.debian.org/ 3 // contributed by Isaac Gouy 4 5 function ack(m,n){ 6 if (m==0) { return n+1; } 7 if (n==0) { return ack(m-1,1); } 8 return ack(m-1, ack(m,n-1) ); 9 } 10 11 function fib(n) { 12 if (n < 2){ return 1; } 13 return fib(n-2) + fib(n-1); 14 } 15 16 function tak(x,y,z) { 17 if (y >= x) return z; 18 return tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y)); 19 } 20 21 for ( var i = 3; i <= 5; i++ ) { 22 ack(3,i); 23 fib(17.0+i); 24 tak(3*i+3,2*i+2,i+1); 25 } 26