LCM: Difference between revisions

Jump to navigation Jump to search
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
For positive integer arguments, the least common multiple is the smallest positive number which is divisible by both numbers. If one of the arguments is zero, the LCM function returns zero.
For positive integer arguments, the least common multiple is 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>
<syntaxhighlight lang=apl>
       ∘.∧⍨ 0,⍳10
       ∘.∧⍨ 0,⍳10
0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0
Line 20: Line 20:
</source>{{Works in|[[Dyalog APL]]}}
</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).
While the mathematical definition of LCM does not cover non-integers, some implementations accept them as arguments. In this case, the return value of <syntaxhighlight lang=apl inline>R←X∧Y</source> is chosen so that both <syntaxhighlight lang=apl inline>R÷X</source> and <syntaxhighlight 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>
<syntaxhighlight lang=apl>
       0.9∧25÷6
       0.9∧25÷6
112.5
112.5
Retrieved from ‘https://aplwiki.com/wiki/LCM