(...numbers)
| 665 | //======// |
| 666 | { |
| 667 | const gcd = (...numbers) => { |
| 668 | const [head, ...tail] = numbers; |
| 669 | if (numbers.length === 1) return head; |
| 670 | if (numbers.length > 2) return gcd(head, gcd(...tail)); |
| 671 | |
| 672 | let [a, b] = [head, ...tail]; |
| 673 | |
| 674 | while (true) { |
| 675 | if (b === 0) return a; |
| 676 | a = a % b; |
| 677 | if (a === 0) return b; |
| 678 | b = b % a; |
| 679 | } |
| 680 | }; |
| 681 | |
| 682 | const reduce = (...numbers) => { |
| 683 | const divisor = gcd(...numbers); |