/* Fraction.js v4.1.2 23/05/2021 https://www.xarg.org/2014/03/rational-numbers-in-javascript/ Copyright (c) 2021, Robert Eisele (robert@xarg.org) Dual licensed under the MIT or GPL Version 2 licenses. */ (function(A){function n(a,c){var b=0,d=1,f=1,m=0,l=0,r=0,w=1,t=1,g=0,h=1,u=1,p=1;if(void 0!==a&&null!==a)if(void 0!==c)b=a,d=c,f=b*d;else switch(typeof a){case "object":"d"in a&&"n"in a?(b=a.n,d=a.d,"s"in a&&(b*=a.s)):0 in a?(b=a[0],1 in a&&(d=a[1])):x();f=b*d;break;case "number":0>a&&(f=a,a=-a);if(0===a%1)b=a;else if(0=h&&1E7>=p;)if(b=(g+u)/(h+p),a===b){1E7>=h+p?(b=g+u,d=h+p):p>h?(b=u,d=p):(b=g,d=h);break}else a>b?(g+=u, h+=p):(u+=g,p+=h),1E7f?-1:1;e.n=Math.abs(b);e.d=Math.abs(d)}function y(a){function c(){var d=Error.apply(this,arguments);d.name=this.name=a;this.stack=d.stack;this.message=d.message}function b(){}b.prototype=Error.prototype;c.prototype=new b;return c}function q(a,c){isNaN(a=parseInt(a,10))&&x();return a*c}function x(){throw new C; }function z(a){for(var c={},b=a,d=2,f=4;f<=b;){for(;0===b%d;)b/=d,c[d]=(c[d]||0)+1;f+=1+2*d++}b!==a?1e.s?new k(Math.pow(this.s*this.d,e.n),Math.pow(this.n,e.n)):new k(Math.pow(this.s*this.n,e.n),Math.pow(this.d,e.n));if(0>this.s)return null;var b=z(this.n),d=z(this.d),f=1,m=1,l;for(l in b)if("1"!==l){if("0"===l){f=0;break}b[l]*= e.n;if(0===b[l]%e.d)b[l]/=e.d;else return null;f*=Math.pow(l,b[l])}for(l in d)if("1"!==l){d[l]*=e.n;if(0===d[l]%e.d)d[l]/=e.d;else return null;m*=Math.pow(l,d[l])}return 0>e.s?new k(m,f):new k(f,m)},equals:function(a,c){n(a,c);return this.s*this.n*e.d===e.s*e.n*this.d},compare:function(a,c){n(a,c);var b=this.s*this.n*e.d-e.s*e.n*this.d;return(0b)},simplify:function(a){function c(m){return 1===m.length?new k(m[0]):c(m.slice(1)).inverse().add(m[0])}if(isNaN(this.n)||isNaN(this.d))return this; var b=this.abs().toContinued();a=a||.001;for(var d=0;dthis.s&&(b+="-");1===f?b+=d:(a&&0<(c=Math.floor(d/f))&&(b=b+c+" ",d%=f),b=b+d+"/",b+=f);return b},toLatex:function(a){var c,b="",d=this.n,f=this.d;0>this.s&& (b+="-");1===f?b+=d:(a&&0<(c=Math.floor(d/f))&&(b+=c,d%=f),b=b+"\\frac{"+d+"}{"+f,b+="}");return b},toContinued:function(){var a=this.n,c=this.d,b=[];if(isNaN(a)||isNaN(c))return b;do{b.push(Math.floor(a/c));var d=a%c;a=c;c=d}while(1!==a);return b},toString:function(a){var c=this.n,b=this.d;if(isNaN(c)||isNaN(b))return"NaN";var d;a:{for(d=b;0===d%2;d/=2);for(;0===d%5;d/=5);if(1===d)d=0;else{for(var f=10%d,m=1;1!==f;m++)if(f=10*f%d,2E3>= 1)l&1&&(r=r*m%b);m=r;for(l=0;300>l;l++){if(f===m){m=l;break a}f=10*f%b;m=10*m%b}m=0}f=-1===this.s?"-":"";f+=c/b|0;(c=c%b*10)&&(f+=".");if(d){for(a=m;a--;)f+=c/b|0,c%=b,c*=10;f+="(";for(a=d;a--;)f+=c/b|0,c%=b,c*=10;f+=")"}else for(a=a||15;c&&a--;)f+=c/b|0,c%=b,c*=10;return f}};"function"===typeof define&&define.amd?define([],function(){return k}):"object"===typeof exports?(Object.defineProperty(k,"__esModule",{value:!0}),k["default"]=k,k.Fraction=k,module.exports=k):A.Fraction=k})(this);