Open ocyzl opened 5 years ago
We can compare with multiplication. Here we have a neutral element 1. ( 3 4 1) => 12 ( 3 4) => 12 The general rule is that we can remove the neutral element from the arguments without changing the results. Therefore: ( 1) => 1 () => 1 In other words we are forced to define the empty product as 1.
We attempt to transfer this principle to lcm
, and thus needs to find a value neutral
which satisfies:
(lcm a neutral) = (lcm a) for all a
In particular (lcm 2 neutral) = (lcm 2) = 2 (lcm 3 neutral) = (lcm 3) = 3 etc So all integers a needs to be a factor of our neutral element.
The value we need is the "product of all integers" - which strictly speaking isn't a number - so we compromise and choose +inf.0 instead.
Another way of thinking:
compare lcm
and gcd
to min
and max
The neutral elements for min
and max
respectively are +inf.0
and -inf.0
.
We attempt to transfer this principle to
lcm
, and thus needs to find a valueneutral
which satisfies:(lcm a neutral) = (lcm a) for all a
I agree, but 1 satisfies that equation, not infinity. "lcm" stands for "least common multiple", i.e., the smallest number that is a multiple of all the arguments. Since every number is a multiple of 1, including 1 as an additional argument doesn't change the result.
You are right!
søn. 17. mar. 2019 kl. 09.10 skrev ocyzl notifications@github.com:
We attempt to transfer this principle to lcm, and thus needs to find a value neutral which satisfies:
(lcm a neutral) = (lcm a) for all a
I agree, but 1 satisfies that equation, not infinity. "lcm" stands for "least common multiple", i.e., the smallest number that is a multiple of all the arguments. Since every number is a multiple of 1, including 1 as an additional argument doesn't change the result.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/407#issuecomment-473627878, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcLxQSJcLdfyqUpf0cPdpF5ndB84V9Bks5vXfiNgaJpZM4b4Ogk .
-- -- Jens Axel Søgaard
https://www.scheme.com/tspl4/objects.html#./objects:s110 says:
1 makes sense to me. What's the argument for infinity?