LCM (∧
) is a dyadic scalar function which returns the Least Common Multiple of two integer arguments. It is an extension of And which maintains the same results on Boolean arguments and the same identity element 1, in the same way that GCD extends Or.
Examples
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.
<syntaxhighlight lang=apl>
∘.∧⍨ 0,⍳10
0 0 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8 9 10
0 2 2 6 4 10 6 14 8 18 10
0 3 6 3 12 15 6 21 24 9 30
0 4 4 12 4 20 12 28 8 36 20
0 5 10 15 20 5 30 35 40 45 10
0 6 6 6 12 30 6 42 24 18 30
0 7 14 21 28 35 42 7 56 63 70
0 8 8 24 8 40 24 56 8 72 40
0 9 18 9 36 45 18 63 72 9 90
0 10 10 30 20 10 30 70 40 90 10
</source>
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 Gaussian integers, when X and/or Y are complex numbers).
<syntaxhighlight lang=apl>
0.9∧25÷6
112.5
112.5÷0.9(25÷6)
125 27
2J2∧3J1
6J2
6J2÷2J2 3J1
2J¯1 2
</source>
Description
The LCM of two numbers is their product divided by the GCD.
External links
Documentation
APL built-ins [edit]
|
Primitives (Timeline) |
Functions
|
Scalar
|
Monadic
|
Conjugate ∙ Negate ∙ Signum ∙ Reciprocal ∙ Magnitude ∙ Exponential ∙ Natural Logarithm ∙ Floor ∙ Ceiling ∙ Factorial ∙ Not ∙ Pi Times ∙ Roll ∙ Type ∙ Imaginary ∙ Square Root ∙ Round
|
Dyadic
|
Add ∙ Subtract ∙ Times ∙ Divide ∙ Residue ∙ Power ∙ Logarithm ∙ Minimum ∙ Maximum ∙ Binomial ∙ Comparison functions ∙ Boolean functions (And, Or, Nand, Nor) ∙ GCD ∙ LCM ∙ Circular ∙ Complex ∙ Root
|
Non-Scalar
|
Structural
|
Shape ∙ Reshape ∙ Tally ∙ Depth ∙ Ravel ∙ Enlist ∙ Table ∙ Catenate ∙ Reverse ∙ Rotate ∙ Transpose ∙ Raze ∙ Mix ∙ Split ∙ Enclose ∙ Nest ∙ Cut (K) ∙ Pair ∙ Link ∙ Partitioned Enclose ∙ Partition
|
Selection
|
First ∙ Pick ∙ Take ∙ Drop ∙ Unique ∙ Identity ∙ Stop ∙ Select ∙ Replicate ∙ Expand ∙ Set functions (Intersection ∙ Union ∙ Without) ∙ Bracket indexing ∙ Index ∙ Cartesian Product ∙ Sort
|
Selector
|
Index generator ∙ Grade ∙ Index Of ∙ Interval Index ∙ Indices ∙ Deal ∙ Prefix and suffix vectors
|
Computational
|
Match ∙ Not Match ∙ Membership ∙ Find ∙ Nub Sieve ∙ Encode ∙ Decode ∙ Matrix Inverse ∙ Matrix Divide ∙ Format ∙ Execute ∙ Materialise ∙ Range
|
Operators |
Monadic
|
Each ∙ Commute ∙ Constant ∙ Replicate ∙ Expand ∙ Reduce ∙ Windowed Reduce ∙ Scan ∙ Outer Product ∙ Key ∙ I-Beam ∙ Spawn ∙ Function axis ∙ Identity (Null, Ident)
|
Dyadic
|
Bind ∙ Compositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner Product ∙ Determinant ∙ Power ∙ At ∙ Under ∙ Rank ∙ Depth ∙ Variant ∙ Stencil ∙ Cut ∙ Direct definition (operator) ∙ Identity (Lev, Dex)
|
Quad names
|
Index origin ∙ Comparison tolerance ∙ Migration level ∙ Atomic vector
|