summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/fannkuch.js
blob: a6154f2dfa94245619b028aa120533e2fb658205 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function fannkuch() {
   var count = Array(8);
   var r = 8;
   var done = 0;
   while (done < 40) {
      // write-out the first 30 permutations
      done += r;
      while (r != 1) { count[r - 1] = r; r--; }
      while (true) {
         count[r] = count[r] - 1;
         if (count[r] > 0) break;
         r++;
      }
   }
   return done;
}
assertEq(fannkuch(), 41);