18 lines
466 B
JavaScript
18 lines
466 B
JavaScript
|
|
export const gcd = (a, b) => {
|
||
|
|
return b === 0 ? a : gcd(b, a % b);
|
||
|
|
};
|
||
|
|
export const numWord = (value, words) => {
|
||
|
|
const normalized = Math.abs(value) % 100;
|
||
|
|
const remainder = normalized % 10;
|
||
|
|
if (normalized > 10 && normalized < 20) {
|
||
|
|
return words[2];
|
||
|
|
}
|
||
|
|
if (remainder > 1 && remainder < 5) {
|
||
|
|
return words[1];
|
||
|
|
}
|
||
|
|
if (remainder === 1) {
|
||
|
|
return words[0];
|
||
|
|
}
|
||
|
|
return words[2];
|
||
|
|
};
|
||
|
|
//# sourceMappingURL=math.js.map
|