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,u=1n,f=0n;for(;0n!==n;){consto=t/n,i=t%n,g=r-u*o,c=e-f*o;t=n,n=i,r=u,e=f,u=g,f=c}return{g:t,x:r,y:e}}functione(t,r){lete="number"==typeoft?BigInt(n(t)):n(t),u="number"==typeofr?BigInt(n(r)):n(r);if(0n===e)returnu;if(0n===u)returne;letf=0n;for(;0n===(1n&(e|u));)e>>=1n,u>>=1n,f++;for(;0n===(1n&e);)e>>=1n;do{for(;0n===(1n&u);)u>>=1n;if(e>u){constn=e;e=u,u=n}u-=e}while(0n!==u);returne<<f}functionu(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)}functionf(n,t){returnn>=t?n:t}functiono(n,t){returnn>=t?t:n}functioni(n,t){if("number"==typeofn&&(n=BigInt(n)),"number"==typeoft&&(t=BigInt(t)),t<=0n)returnNaN;constr=n%t;returnr<0n?r+t:r}functiong(n,t){try{conste=r(i(n,t),t);return1n!==e.g?NaN:i(e.x,t)}catch(n){returnNaN}}functionc(t,r,e){if("number"==typeoft&&(t=BigInt(t)),"number"==typeofr&&(r=BigInt(r)),"number"==typeofe&&(e=BigInt(e)),e<=0n)returnNaN;if(1n===e)returnBigInt(0);if(t=i(t,e),r<0n)returng(c(t,n(r),e),e);letu=1n;for(;r>0;)r%2n===1n&&(u=u*t%e),r/=2n,t=t**2n%e;returnu}export{nasabs,tasbitLength,raseGcd,easgcd,uaslcm,fasmax,oasmin,gasmodInv,casmodPow,iastoZn};