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 Great Computer Language Shootout |
michael@0 | 2 | // http://shootout.alioth.debian.org |
michael@0 | 3 | // |
michael@0 | 4 | // Contributed by Ian Osgood |
michael@0 | 5 | |
michael@0 | 6 | var result = []; |
michael@0 | 7 | |
michael@0 | 8 | function pad(n,width) { |
michael@0 | 9 | var s = n.toString(); |
michael@0 | 10 | while (s.length < width) s = ' ' + s; |
michael@0 | 11 | return s; |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | function primes(isPrime, n) { |
michael@0 | 15 | var i, count = 0, m = 10000<<n, size = m+31>>5; |
michael@0 | 16 | |
michael@0 | 17 | for (i=0; i<size; i++) isPrime[i] = 0xffffffff; |
michael@0 | 18 | |
michael@0 | 19 | for (i=2; i<m; i++) |
michael@0 | 20 | if (isPrime[i>>5] & 1<<(i&31)) { |
michael@0 | 21 | for (var j=i+i; j<m; j+=i) |
michael@0 | 22 | result.push(isPrime[j>>5] &= ~(1<<(j&31))); |
michael@0 | 23 | count++; |
michael@0 | 24 | } |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function sieve() { |
michael@0 | 28 | for (var i = 4; i <= 4; i++) { |
michael@0 | 29 | var isPrime = new Array((10000<<i)+31>>5); |
michael@0 | 30 | primes(isPrime, i); |
michael@0 | 31 | } |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | sieve(); |
michael@0 | 35 | |
michael@0 | 36 | var ret = 0; |
michael@0 | 37 | for (var i = 0; i < result.length; ++i) |
michael@0 | 38 | ret += result[i]; |
michael@0 | 39 | |
michael@0 | 40 | assertEq(ret, -211235557404919) |