Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // The Computer Language Shootout |
michael@0 | 2 | // http://shootout.alioth.debian.org/ |
michael@0 | 3 | // contributed by Isaac Gouy |
michael@0 | 4 | |
michael@0 | 5 | function ack(m,n){ |
michael@0 | 6 | if (m==0) { return n+1; } |
michael@0 | 7 | if (n==0) { return ack(m-1,1); } |
michael@0 | 8 | return ack(m-1, ack(m,n-1) ); |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | function fib(n) { |
michael@0 | 12 | if (n < 2){ return 1; } |
michael@0 | 13 | return fib(n-2) + fib(n-1); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | function tak(x,y,z) { |
michael@0 | 17 | if (y >= x) return z; |
michael@0 | 18 | return tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y)); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | var ret = 0; |
michael@0 | 22 | for ( var i = 3; i <= 5; i++ ) { |
michael@0 | 23 | ret += ack(3,i); |
michael@0 | 24 | ret += fib(17.0+i); |
michael@0 | 25 | ret += tak(3*i+3,2*i+2,i+1); |
michael@0 | 26 | } |
michael@0 | 27 | assertEq(ret, 57775); |