title: modpow biginteger javascript
body: <p>I look for a good algorithme JavaScript because I tried this with node.js :</p>
  
  <pre><code>function modpow_3(a,n, module){
  var u = BigInt('1');
  var e = equals(a, u);
  if( e) return a;
  if(equalsZero(a)) return a;
  if(pair(n)){
      x= modpow_2(a, (divide(n, BigInt('2'))));
      return mod(multiply(x,x), module);
  }else{      
      x= modpow_2(a, (divide(subs(n, BigInt(1) ), BigInt('2'))));
      return mod(multiply(multiply(x,x), a), module);
  }
  
  }
  </code></pre>
  
  <p>But I have an error : 
  RangeError: Maximum call stack size exceeded</p>