functionn(n){returnn>=0?n:-n}functiont(n){if("number"==typeofn&&(n=BigInt(n)),1n===n)return1;lett=1;do{t++}while((n>>=1n)>1n);returnt}functionr(n,t){if("number"==typeofn&&(n=BigInt(n)),"number"==typeoft&&(t=BigInt(t)),n<=0n||t<=0n)thrownewRangeError("a and b MUST be > 0");letr=0n,e=1n,o=1n,u=0n;for(;0n!==n;){consti=t/n,f=t%n,g=r-o*i,b=e-u*i;t=n,n=f,r=o,e=u,o=g,u=b}return{g:t,x:r,y:e}}functione(t,r){lete="number"==typeoft?BigInt(n(t)):n(t),o="number"==typeofr?BigInt(n(r)):n(r);if(0n===e)returno;if(0n===o)returne;letu=0n;for(;0n===(1n&(e|o));)e>>=1n,o>>=1n,u++;for(;0n===(1n&e);)e>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(e>o){constn=e;e=o,o=n}o-=e}while(0n!==o);returne<<u}functiono(t,r){return"number"==typeoft&&(t=BigInt(t)),"number"==typeofr&&(r=BigInt(r)),0n===t&&0n===r?BigInt(0):n(t*r)/e(t,r)}functionu(n,t){returnn>=t?n:t}functioni(n,t){returnn>=t?t:n}functionf(n,t){if("number"==typeofn&&(n=BigInt(n)),"number"==typeoft&&(t=BigInt(t)),t<=0n)thrownewRangeError("n must be > 0");constr=n%t;returnr<0n?r+t:r}functiong(n,t){conste=r(f(n,t),t);if(1n!==e.g)thrownewRangeError(`${n.toString()} does not have inverse modulo ${t.toString()}`);returnf(e.x,t)}functionb(t,r,e){if("number"==typeoft&&(t=BigInt(t)),"number"==typeofr&&(r=BigInt(r)),"number"==typeofe&&(e=BigInt(e)),e<=0n)thrownewRangeError("n must be > 0");if(1n===e)return0n;if(t=f(t,e),r<0n)returng(b(t,n(r),e),e);leto=1n;for(;r>0;)r%2n===1n&&(o=o*t%e),r/=2n,t=t**2n%e;returno}export{nasabs,tasbitLength,raseGcd,easgcd,oaslcm,uasmax,iasmin,gasmodInv,basmodPow,fastoZn};