|
|
|
|
|
by CydeWeys
3496 days ago
|
|
I've never used Ruby before, but I learned something interesting when Googling what I thought was a weakness in his preferred solution to the first problem: Apparently, in Ruby, integer types have two internal representations that are flexibly switched between as needed. One representation uses a fixed size (analogous to long/int64 in other languages) and the other representation, Bignum, has an arbitrary size (analogous to Java's BigDecimal). So the simple (1..n).reduce(:lcm) approach should work for n of arbitrary size, though I don't think it's the most efficient approach. |
|