trusted
183
edits
No edit summary |
(→Extended definition: Split the description for integers and non-integers) |
||
Line 31: | Line 31: | ||
== Extended definition == | == Extended definition == | ||
Many APL implementations extend this function to non-Boolean arguments. In this case, this function behaves as '''[[wikipedia:Least common multiple|Least Common Multiple]]''' or '''LCM'''. For positive integer arguments, it is defined as the smallest positive number which is divisible by both numbers. If one of the arguments is zero, the LCM function returns zero | Many APL implementations extend this function to non-Boolean arguments. In this case, this function behaves as '''[[wikipedia:Least common multiple|Least Common Multiple]]''' or '''LCM'''. For positive integer arguments, it is defined as the smallest positive number which is divisible by both numbers. If one of the arguments is zero, the LCM function returns zero. | ||
<source lang=apl> | <source lang=apl> | ||
Line 46: | Line 46: | ||
0 9 18 9 36 45 18 63 72 9 90 | 0 9 18 9 36 45 18 63 72 9 90 | ||
0 10 10 30 20 10 30 70 40 90 10 | 0 10 10 30 20 10 30 70 40 90 10 | ||
</source>{{Works in|[[Dyalog APL]]}} | |||
While the mathematical definition of LCM does not cover non-integers, some implementations accept them as arguments. In this case, the return value of <source lang=apl inline>R←X∧Y</source> is chosen so that both <source lang=apl inline>R÷X</source> and <source lang=apl inline>R÷Y</source> are integers (or [[wikipedia:Gaussian integer|Gaussian integers]], when X and/or Y are [[complex]] numbers). | |||
<source lang=apl> | |||
0.9∧25÷6 | 0.9∧25÷6 | ||
112.5 | 112.5 |