This function computes n-th power of x.
function int pow (int x, int n) { if (n < 1) return 1; int y = x; while (--n) y *= x; return y; }