[Question]
  [
The least common multiple of a set of positive integers `A` is the smallest postive integer `B` such that, for each `k` in `A`, there exists a positive integer `n` such that `k*n = B`.
Given at least two positive integers as input, output their least common multiple.
## Rules
* Builtins are allowed, but if your solution uses one, you are encouraged to include an alternate solution that does not use GCD/LCM builtins. However, the alternate solution will not count towards your score at all, so it is entirely optional.
* All inputs and outputs will be within the natively-representable range for your language. If your language is natively capable of arbitrarily-large integers, then your solution must work with arbitrarily large inputs and outputs.
## Test cases
```
[7, 2] -> 14
[8, 1] -> 8
[6, 4, 8] -> 24
[8, 2, 1, 10] -> 40
[9, 6, 2, 1, 5] -> 90
[5, 5, 7, 1, 1] -> 35
[4, 13, 8, 8, 11, 1] -> 1144
[7, 2, 2, 11, 11, 8, 5] -> 3080
[1, 6, 10, 3, 4, 10, 7] -> 420
[5, 2, 9, 10, 3, 4, 4, 4, 7] -> 1260
[9, 7, 10, 9, 7, 8, 5, 10, 1] -> 2520
```
  
[Answer]
## JavaScript (ES6), 36 bytes
```
f=(a,i=1)=>a.some(v=>i%v)?f(a,i+1):i
```
Starting from `1` it's the first number that can be divided by all.
```
f=(a,i=1)=>a.some(v=>i%v)?f(a,i+1):i
;
console.log(f([7, 2]));
console.log(f([8, 1]));
console.log(f([6, 4, 8]));
console.log(f([8, 2, 1, 10]));
console.log(f([9, 6, 2, 1, 5]));
console.log(f([5, 5, 7, 1, 1]));
console.log(f([4, 13, 8, 8, 11, 1]));
console.log(f([7, 2, 2, 11, 11, 8, 5]));
console.log(f([1, 6, 10, 3, 4, 10, 7]));
console.log(f([5, 2, 9, 10, 3, 4, 4, 4, 7]));
console.log(f([9, 7, 10, 9, 7, 8, 5, 10, 1]));
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E)/[2sable](https://github.com/Adriandmen/2sable), 2 bytes
```
.¿
```
[Try it online! in 05AB1E](http://05ab1e.tryitonline.net/#code=LsK_&input=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0)  
[or 2sable](http://2sable.tryitonline.net/#code=LsK_&input=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
æl/
```
Reduces by LCM. [Try it online!](http://jelly.tryitonline.net/#code=w6ZsLw&input=&args=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0) or [verify all test cases](http://jelly.tryitonline.net/#code=w6ZsLwrDh-KCrEc&input=&args=WwogICAgWzcsIDJdLAogICAgWzgsIDFdLAogICAgWzYsIDQsIDhdLAogICAgWzgsIDIsIDEsIDEwXSwKICAgIFs5LCA2LCAyLCAxLCA1XSwKICAgIFs1LCA1LCA3LCAxLCAxXSwKICAgIFs0LCAxMywgOCwgOCwgMTEsIDFdLAogICAgWzcsIDIsIDIsIDExLCAxMSwgOCwgNV0sCiAgICBbMSwgNiwgMTAsIDMsIDQsIDEwLCA3XSwKICAgIFs1LCAyLCA5LCAxMCwgMywgNCwgNCwgNCwgN10sCiAgICBbOSwgNywgMTAsIDksIDcsIDgsIDUsIDEwLCAxXQpd).
## Alternate version, 6 bytes
```
ÆE»/ÆẸ
```
[Try it online!](http://jelly.tryitonline.net/#code=w4ZFwrsvw4bhurg&input=&args=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0) or [verify all test cases](http://jelly.tryitonline.net/#code=w4ZFwrsvw4bhurgKw4figqxH&input=&args=WwogICAgWzcsIDJdLAogICAgWzgsIDFdLAogICAgWzYsIDQsIDhdLAogICAgWzgsIDIsIDEsIDEwXSwKICAgIFs5LCA2LCAyLCAxLCA1XSwKICAgIFs1LCA1LCA3LCAxLCAxXSwKICAgIFs0LCAxMywgOCwgOCwgMTEsIDFdLAogICAgWzcsIDIsIDIsIDExLCAxMSwgOCwgNV0sCiAgICBbMSwgNiwgMTAsIDMsIDQsIDEwLCA3XSwKICAgIFs1LCAyLCA5LCAxMCwgMywgNCwgNCwgNCwgN10sCiAgICBbOSwgNywgMTAsIDksIDcsIDgsIDUsIDEwLCAxXQpd).
### How it works
```
ÆE»/ÆẸ  Main link. Argument: A (array)
ÆE      Yield all prime exponents of each integer in A.
  »/    Reduce columns (exponents that correspond to the same prime) by maximum.
    ÆẸ  Turn the resulting array of prime exponents into the corresponding integer.
```
[Answer]
# Python, ~~69~~ ~~65~~ ~~52~~ 50 bytes
```
A=lambda l,i=1:any(i%a for a in l)and A(l,i+1)or i
```
2 bytes saved thanks to Dennis!
Pretty straightforward recursive solution, you will need to make the recursion limit a bit higher for some of the test cases to work.
[Answer]
# [MATL](http://github.com/lmendo/MATL), 7 bytes
```
&YFX>^p
```
No builtin.
[Try it online!](http://matl.tryitonline.net/#code=JllGWD5ecA&input=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0)
### Explanation
Let's take input `[8, 2, 1, 10]` as an example.
```
&YF    % Take array implicitly. Push vector of prime factors and matrix of exponents 
       % of factorization, where each row represents one of the input numbers
       %   STACK: [2 3 5], [3 0 0; 1 0 0; 0 0 0; 1 0 1]
X>     % Maximum of each column
       %   STACK: [2 3 5], [3 0 1]
^      % Element-wise power
       %   STACK: [8 1 5]
p      % Product of array
       %   STACK: 40
       % Implicitly display
```
---
*EDIT (June 9, 2017): `YF` with two outputs has been modified in [release 20.1.0](https://github.com/lmendo/MATL/releases/tag/20.1.0): non-factor primes and their (zero) exponents are skipped. This doesn't affect the above code, which works without requiring any changes.*
[Answer]
# Julia (3 Bytes) [Working on Non-Built-in]
```
lcm     # Using LCM built-in (3 Bytes)
```
As Dennis pointed out, I keep forgetting that Julia automatically vectorizes inputs.
## Example:
```
println(lcm(1,2,3,4,5,6,7,8,9)) #Prints 2520
```
[Answer]
## PowerShell v2+, ~~73~~ 60 bytes
```
param($a)for($i=1;($a|?{!($i%$_)}).count-ne$a.count){$i++}$i
```
Takes input `$a`, loops upward from `$i=1` with `$i++`, based on a conditional. The condition is `($a|?{!($i%$_)}).count` being `-n`ot`e`qual to `$a.count`. Meaning, the loop ends when the elements of `$a` that *are* divisors of `$i` is equal to the elements of `$a`. Then, a solitary `$i` is left on the pipeline, and output is implicit.
### Test Cases
```
PS C:\Tools\Scripts\golfing> @(7,2),@(8,1),@(6,4,8),@(8,2,1,10),@(9,6,2,1,5),@(5,5,7,1,1),@(4,13,8,8,11,1)|%{($_-join',')+" -> "+(.\least-common-multiple.ps1 $_)}
7,2 -> 14
8,1 -> 8
6,4,8 -> 24
8,2,1,10 -> 40
9,6,2,1,5 -> 90
5,5,7,1,1 -> 35
4,13,8,8,11,1 -> 1144
PS C:\Tools\Scripts\golfing> @(7,2,2,11,11,8,5),@(1,6,10,3,4,10,7),@(5,2,9,10,3,4,4,4,7),@(9,7,10,9,7,8,5,10,1)|%{($_-join',')+" -> "+(.\least-common-multiple.ps1 $_)}
7,2,2,11,11,8,5 -> 3080
1,6,10,3,4,10,7 -> 420
5,2,9,10,3,4,4,4,7 -> 1260
9,7,10,9,7,8,5,10,1 -> 2520
```
[Answer]
# Actually, ~~12~~ 1 byte
Golfing suggestions are still welcome, though I'm not sure how to improve on the raw LCM built-in. [Try it online!](http://actually.tryitonline.net/#code=4pay&input=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0) 
```
▲
```
A 12-byte version without the built-in. Golfing suggestions welcome. [Try it online!](http://actually.tryitonline.net/#code=4pWXMmDilZxA4pmAJc6jWWDilZNO&input=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0)
```
╗2`╜@♀%ΣY`╓N
```
**Ungolfing**
```
          Implicit input array.
╗         Save array in register 0.
2`...`╓   Starting with f(0), find the first (two) x where f(x) returns a truthy value.
          These two values will be 0 and our LCM.
  ╜         Push array from register 0.
  @         Swap the top two values. Stack: x, array
  ♀%        Map % over x and array, returning (x % item) for each item in array.
  ΣY        If the sum of all the modulos equals 0, x is either 0 or our LCM.
N         Push the last (second) value of our results. This is our LCM.
          Implicit return.
```
[Answer]
# Cheddar, 33 bytes
```
(n,i=1)f->n.any(i&(%))?f(n,i+1):i
```
Nothing super new.
## Ungolfed
```
(n, i = 1) f ->
  n.any(j -> i % j) ?
    f(n, i + 1) :
    i
```
Basically this starts at one and keeps increasing until it finds an LCM
[Answer]
# JavaScript (ES6), ~~63~~ 59 bytes
```
f=([x,...a])=>a[0]?x*f(a)/(g=(m,n)=>n?g(n,m%n):m)(x,f(a)):x
```
Recursively finds the LCM of the last two elements.
[Answer]
# Mathematica, 3 bytes
```
LCM
```
Usage: 
```
In[1]:= LCM[9, 7, 10, 9, 7, 8, 5, 10, 1]                                        
Out[1]= 2520
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog) v2, 8 bytes
```
{×↙Xℕ₁}ᵛ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3wv/rw9EdtMyMetUx91NQIFJn9/3@0QrS5jlGsTrSFjiGQNNMx0bEA84x0DHUMDYBMSx0zMMcUyDbVMdUxB0kA2SY6hsY6FkBoCOEDjQGpMwQhC7BqQ6BOQwMdY6CZQMocrN9IxxImBoLmYAvMQUIgCqgPxDSMVYgFAA "Brachylog – Try It Online")
It's funny just how directly this maps on to the definition given in the challenge.
```
{     }ᵛ    Each element of
            the input
 ×          multiplied by
  ↙X        some arbitrary and inconsistent integer
    ℕ₁      is a natural number,
       ᵛ    which is the same for each element,
            and is the output.
```
A suspiciously slow but significantly shorter solution:
# [Brachylog](https://github.com/JCumin/Brachylog) v2, 5 bytes
```
f⊇p~d
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRuX/eobcOjpqaHuzprH26d8D/tUVd7QV3K///RCtHmOkaxOtEWOoZA0kzHRMcCzDPSMdQxNAAyLXXMwBxTINtUx1THHCQBZJvoGBrrWAChIYQPNAakzhCELMCqDYE6DQ10jIFmAilzsH4jHUuYGAiagy0wBwmBKKA@ENMwViEWAA "Brachylog – Try It Online")
Takes input through the output variable and gives output through the input variable. Rips right through the first four test cases but I'm still waiting on the fifth... Ordinarily, I'd still make it my primary solution and just trust that it works correctly, but I don't know why it hasn't confirmed that 90 is the LCM of `9, 6, 2, 1, 5` when I *gave it 90* twenty minutes ago.
(Edit: It confirmed the answer after no more than 16 hours, and generated it alongside the LCM of `5, 5, 7, 1, 1` after about two days.)
```
         The output variable
   ~d    with duplicates removed
  p      is a permutation of
 ⊇       a sublist of
f        the factors of
         the input variable.
```
And another completely different predicate that accidentally more-or-less translates Fatalize's Brachylog v1 solution:
# [Brachylog](https://github.com/JCumin/Brachylog) v2, 10 bytes
```
;.gᵗ↔z%ᵛ0<
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3w31ov/eHW6Y/aplSpPtw628Dm//9ohWhzHaNYnWgLHUMgaaZjomMB5hnpGOoYGgCZljpmYI4pkG2qY6pjDpIAsk10DI11LIDQEMIHGgNSZwhCFmDVhkCdhgY6xkAzgZQ5WL@RjiVMDATNwRaYg4RAFFAfiGkYqxALAA "Brachylog – Try It Online")
This was salvaged from a solution I'd made for [this challenge](https://codegolf.stackexchange.com/questions/127103/lcm-of-rational-numbers) before I realized the output wasn't restricted to being an integer.
```
 .            The output
; gᵗ↔z        paired with each element of
              the input,
      %ᵛ      when the first element of each pair is taken mod the second, is always
        0     zero.
              Furthermore, the output
         <    is strictly greater than
        0     zero.
```
[Answer]
# Dyalog APL, 2 bytes
```
∧/
```
Reduces by LCM. Test it on [TryAPL](http://tryapl.org/?a=lcm%20%u2190%20%u2227/%20%u22C4%20lcm%209%207%2010%209%207%208%205%2010%201&run).
[Answer]
## JavaScript (ES6), 52 bytes
```
a=>a.reduce((l,n)=>l*n/(g=(m,n)=>n?g(n,m%n):m)(l,n))
```
I `reduce`d this answer as much as I could but I'm obviously not going to get anywhere near the simplicity of @Hedi's answer.
[Answer]
# Java 8, ~~75~~ ~~59~~ ~~121~~ 89 bytes
Uses the Euclidean Algorithm and the fact that
LCM(A, B)= A \* B / GCD(A, B)
* ***16** bytes off. Thanks to @carusocomputing*
* *Added Multi-Input +**62** bytes*
* ***32** bytes off. Thanks to @Olivier Grégoire*
Code:
```
public static int lcm(int l, int c){
  for(int i=1;i<=l&&i<=c;++i) 
    if (i%l==0&&i%c==0)
      return l*c/i;
}
public static int lcm(int...x){
  int y=x[0];
  for(int j:x){
    y=lcm(j,y);
  }
  return y;
}
```
Remove line-breaks:
```
int g(int a,int b){return b<1?a:g(b,a%b);}
```
---
```
l->{int l=1;for(int n:a)l=l*n/g(l,n);return l;}
```
[Answer]
# [MATL](http://github.com/lmendo/MATL), 3 bytes
```
&Zm
```
This uses the builtin function with array input.
[Try it online!](http://matl.tryitonline.net/#code=Jlpt&input=WzksIDcsIDEwLCA5LCA3LCA4LCA1LCAxMCwgMV0)
[Answer]
# [Brachylog](http://github.com/JCumin/Brachylog), 17 bytes
```
,.#>=g:?z:%a#=h0,
```
[Try it online!](http://brachylog.tryitonline.net/#code=LC4jPj1nOj96OiVhIz1oMCw&input=Wzk6NzoxMDo5Ojc6ODo1OjEwOjFd&args=Wg)
### Explanation
```
,.#>=               Output is a strictly positive integer
     g:?z           Zip the Output with the Input
         :%a        Compute Output mod I for each I in the Input
            #=h0,   All results must be equal to 0
```
[Answer]
# C#, 50+18 = 68 bytes
50 bytes for method defintion, +18 bytes for LINQ import.
```
using System.Linq;int L(int[]n,int i=1)=>n.All(x=>1>i%x)?i:L(n,i+1);
```
Pretty much the same as a lot of other answers. Counts up recursively until it finds the LCM. I was a bit surprised this didn't get a StackOverflowException, so I also have a non-recursive version which is actually just 1 byte longer.
```
using System.Linq;n=>{for(int i=1;;i++)if(n.All(x=>1>i%x))return i;};
```
Ungolfed:
```
using System.Linq;            // Import LINQ
int L(int[] n, int i = 1) =>  // Function declaration
    n.All(x => 1 > i % x)     // Check if each x in n divides i
        ? i                   // And if so return i
        : L(n, i + 1)         // Otherwise increment i and recurse
;
```
[Answer]
# [Perl 6](https://perl6.org), 10 bytes
```
{[lcm] @_}
```
basically the same as:
```
sub ( *@_ ) { @_.reduce: &infix:< lcm > }
```
[Answer]
# J, 11 bytes
```
>./&.(_&q:)
```
There is a solution for **3 bytes** using the LCM builtin.
```
*./
```
## Explanation
```
>./&.(_&q:)  Input: array of integers A
      _&q:   Get the prime exponents of each integer in A
>./&         Reduce by maximum on the lists
   &. _&q:   Convert the list of exponents back to an integer
*./  Input: array of integers A
  /  Reduce using
*.     LCM
```
[Answer]
# CJam, ~~18~~ ~~17~~ 16 bytes
1 byte saved thanks to Martin Ender.
Incrementing until the LCM is found.
```
q~0{)_2$f%:+}g\;
```
[Try it online](http://cjam.tryitonline.net/#code=cU4vezpRUW8iIC0-ICJvOwoKUX4weylfMiRmJTorfWdcOwoKXW9Ob30vICAgICAgICAgICAgIA&input=WzcgMl0KWzggMV0KWzYgNCA4XQpbOCAyIDEgMTBdCls5IDYgMiAxIDVdCls1IDUgNyAxIDFdCls0IDEzIDggOCAxMSAxXQpbNyAyIDIgMTEgMTEgOCA1XQpbMSA2IDEwIDMgNCAxMCA3XQpbNSAyIDkgMTAgMyA0IDQgNCA3XQpbOSA3IDEwIDkgNyA4IDUgMTAgMV0)
[Answer]
## Racket 13 bytes
lcm is a built-in function in Racket:
```
(apply lcm l)
```
Testing:
```
(define (f l)
   (apply lcm l))
(f (list 7 2)) 
(f (list 8 1)) 
(f (list 6 4 8)) 
(f (list 8 2 1 10)) 
(f (list 9 6 2 1 5))
(f (list 5 5 7 1 1)) 
(f (list 4 13 8 8 11 1))
(f (list 7 2 2 11 11 8 5))
(f (list 1 6 10 3 4 10 7))
(f (list 5 2 9 10 3 4 4 4 7)) 
(f (list 9 7 10 9 7 8 5 10 1))
```
Output: 
```
14
8
24
40
90
35
1144
3080
420
1260
2520
```
[Answer]
# R, 36 bytes (not builtin)
```
v=scan();i=1;while(any(i%%v))i=i+1;i
```
Takes the input. Then tests each positive integer by taking the mod.
[Answer]
# APOL, 49 bytes
`v(0 1);v(1 i);w(⊕(ƒ(s(¹) %(⁰ I(∋)))) ∆(0));-(⁰ 1)`
This could almost certaintly be made shorter, maybe I'll come back to it later.
[Answer]
# Pyth, 9 bytes
```
.U/*bZibZ
```
A program that takes input of a list on STDIN and prints the result.
[Try it online](http://pyth.herokuapp.com/?code=.U%2F%2abZibZ&debug=0) or [verify all test cases](http://pyth.herokuapp.com/?code=j%22+-%3E+%22%2CQ.U%2F%2abZibZ&test_suite=1&test_suite_input=%5B7%2C+2%5D%0A%5B8%2C+1%5D%0A%5B6%2C+4%2C+8%5D%0A%5B8%2C+2%2C+1%2C+10%5D%0A%5B9%2C+6%2C+2%2C+1%2C+5%5D%0A%5B5%2C+5%2C+7%2C+1%2C+1%5D%0A%5B4%2C+13%2C+8%2C+8%2C+11%2C+1%5D%0A%5B7%2C+2%2C+2%2C+11%2C+11%2C+8%2C+5%5D%0A%5B1%2C+6%2C+10%2C+3%2C+4%2C+10%2C+7%5D%0A%5B5%2C+2%2C+9%2C+10%2C+3%2C+4%2C+4%2C+4%2C+7%5D%0A%5B9%2C+7%2C+10%2C+9%2C+7%2C+8%2C+5%2C+10%2C+1%5D&debug=0)
**How it works**
```
.U/*bZibZ  Program. Input: Q
.U         Reduce Q by (implicit input fill):
   *bZ      Product of current and next value
  /   ibZ   divided by GCD of current and next value
           Implicitly print
```
[Answer]
## Haskell, 10 bytes
```
foldr1 lcm
```
Usage example: `foldl1 lcm [5,2,9,10,3,4,4,4,7]` -> `1260`.
[Answer]
## [Pip](http://github.com/dloscutoff/pip), 10 bytes
```
W$+o%g++oo
```
Uses the "try every number until one works" strategy. [Try it online!](http://pip.tryitonline.net/#code=VyQrbyVnKytvbw&input=&args=MQ+MTE+OA+OA+NA+MTM)
```
            o is preinitialized to 1, g is list of cmdline args
   o%g      Mod o by each arg
 $+         Sum (truthy if any nonzero, falsy if all zero)
W           Loop while that expression is truthy:
      ++o     Increment o
         o  Autoprint o
```
[Answer]
## PHP, ~~42~~ 74 bytes
```
for(;($p=++$f*$argv[1])%$argv[2];);echo$p;
```
straight forward:  
loop `$f` from 1 upwards; if `$f*$a` divides through `$b` without a remainder, the LCM is found.
---
I totally had overread the `at least` ... here´s the code for any number of parameters:
```
for(;$i<$argc;)for($p=$argv[$i=1]*++$f;++$i<$argc&$p%$argv[$i]<1;);echo$p;
```
Loop `$f` from 1 upwards while inner loop has not run to $argc.  
Loop `$i` from `2` to `$argc-1` while `$f*$argv[1]` divides through `$argv[$i]` without a remainder.  
both loops broken: print `$f*$argument 1`.
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 46 bytes
```
l([],1).
l([X|Y],P):-l(Y,Q),P is X*Q/gcd(X,Q).
```
[Try it online!](https://tio.run/nexus/prolog-swi#TVDLCsJAELv7FUNPrUy1s31s68Vf0FuL9CBapFBE3IIX/12zD6kwhySTzYT9TPGpZ0k2K4D23fV8SHbpFHd8TPhAo6F2fdzeLte4hbL57FOCUTOpnkmKhC2tAUFrzyqmAgSCWvYKFkwGtci82jBVv0UJvQl6Ccqk/QPoeel1hEqOYDcSliJFOKJdlgorcS4bm2d1CBZ3UDJorqJF2hZSy2W8b/49fqxLVLUU197jUe0KW24bqdLFvZ7jPEz3OJoHMxt6nI2J8H9f "Prolog (SWI) – TIO Nexus")
Another solution, 59 bytes:
```
l(A,X):-between(1,inf,X),forall(member(Y,A),X mod Y=:=0),!.
```
[Answer]
# [J](http://jsoftware.com/), 34 bytes
```
*/@((0 1+])^:(*@+/@:|*/)^:_>./,1:)
```
A **while** loop iterating through multiples of the largest number in input.
[Try it online!](https://tio.run/##y/r/P81WT0FL30FDw0DBUDtWM85KQ8tBW9/BqkZLH8iJt9PT1zG00vyfmpyRr6CQpqBgYWxkqWBoagAGCoZGRkDClAssraWnj136PwA "J – Try It Online")
]