SyntaxFix
Write A Post
Hire A Developer
Questions
In Ruby, it's as simple as:
> [2, 3, 4, 6].reduce(:lcm) => 12 > [16, 32, 96].reduce(:gcd) => 16
(tested on Ruby 2.2.10 and 2.6.3.)