[Question]
  [
The least common multiple (LCM) of a set of numbers `A` is the smallest integer `b` such that `b/a` is an integer for all integers `a` in `A`. This definition can be extended to rational numbers!
# Task
Find the smallest positive **rational** `b` such that `b/a` is an **integer** for all **rationals** `a` in the input.
# Rules
* Standard loopholes are forbidden.
* You may take numerators and denominators separately in the input, but may not take doubles, floats, etc.
* The input may not be fully reduced.
* You may take integer inputs as rationals with denominator of `1`.
* Submissions that would feed rational numbers to an LCM/GCD builtin are allowed, but non-competing.
# Test Cases
```
In:  3
Out: 3
In:  1/17
Out: 1/17
In:  1/2, 3/4
Out: 3/2
In:  1/3, 2/8
Out: 1
In:  1/4, 3
Out: 3
In:  2/5, 3
Out: 6
In:  1/2, 3/4, 5/6, 7/8
Out: 105/2
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so submissions using the fewest bytes win!
  
[Answer]
# J, 3 bytes
```
*./
```
Given a list of rational inputs, this folds LCM through it.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 19 bytes
```
g/:@$€Z©Ḣæl/;®Ḣg/$¤
```
[Try it online!](https://tio.run/##y0rNyan8/z9d38pB5VHTmqhDKx/uWHR4WY6@9aF1QFa6vsqhJf8PtwOl/v@P5uKMjjbWMYyN1QGxDHUMzeFMo1gdoJQJnG8M5BvpWMD5JmB5mFYjHVMUPkK/TrSpjhmQNIfojQUA "Jelly – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
:g/æl/;g/}ɗ/
```
[Try it online!](https://tio.run/##y0rNyan8/98qXf/wshx963T92pPT9f8fbv//PzraUEfBWEfBVEfBPFZHIdpIR8FER8FMR8EiNhYA "Jelly – Try It Online")
Takes input as `[[list of numerators], [list of denominators]]`. [+2 bytes](https://tio.run/##y0rNyan8/z/KKl1f5fCyHH3rdP3ak9P1////Hx1tqKNgFKujEG2so2ACok11FMxAtLmOgkVsLAA) to take input as a list of `[numerator, denominator]` pairs
## How it works
```
:g/æl/;g/}ɗ/ - Main link. Takes a pair of lists [N, D] on the left
  /          - Columnwise reduce by:
 g           -   GCD
:            - Divide, reducing the fractions to their simplest form
          ɗ  - Group the previous 3 links into a dyad f(N, D):
   æl/       -   LCM of N
         }   -   To D:
       g/    -     GCD
      ;      -   Concatenate
           / - Reduce; Yield f(N, D) where N is the first list and D the second
```
The 14 byte version transposes the input with `Z` to get it into the `[N, D]` format, then uses `$` as a "grouping" construct the make the `:g/` act on that
[Answer]
# sed, 374 (373+1) bytes
sed's `-E` flag counts as one byte. Note: I haven't tried to golf this yet, and probably won't for quite some time.  
Input is taken in unary, and output is in unary. Spaces must surround every fraction. Example: `echo " 1/111 111/11111 111111/111 "`.
```
:d;s, (1*)/\1(1*), \1/\22,;s,(1*)(1*)/\2 ,2\1/\2 ,;td;s,1*(1/22*),\1,g;s,(22*/1)1*,\1,g;:r;s,((1*)/1*)2,\1\2,;s,2(1*/(1*)),\2\1,;tr;h;s,1*/,,g;:g;s/^(1*) 1(1*) 1(1*)/1\1 \2 \3/;tg;s/  */ /g;s/^/ /;/1 1/bg;x;s,/1*,,g;s/^( 1*)( 1*)/\1\2\2/;:l;s/^(1*) (1*) \2(1*)/\1\2 \2 \3/;tl;/  $/be;/  /{s/^(1*) 1*  1*( 1*)/ \1\2\2/;bl};s/^(1* 1* )(1*) (1*)/\1\2\3 \3/;bl;:e;G;s, *\n *,/,
```
[Try it online!](https://tio.run/##XZDBasMwDIbvegoddkiMh5B6y85jL2F2CA3dILSjyaEw9urzftluwhqwhX79@iRnmY45D0daIncaeknqIXJSSWYRuue1ZByt6Bxp9RYNnYoZ/Enjyb1IRHsNVRiurpVmHIOYCtIgictoBBG0K30UnkRvA0revc6636JJGbPTQWh1B3MQluJFJFFWGU90AwjjHOQU9vW5Pg3DTGiYN3y5knX38safCfgnGSeP8r2tExin4rjxXsb5pwG93m/gOvBQgONMw0Rv/ptDOnOIEnNmVcXWhL318Wtqtey5C/Lgubs8bcV/5J1Raq2dG2Sn/V6@1s/LecnPr38 "sed – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 65 bytes
```
lambda x:reduce(lambda x,y:x*y/gcd(x,y),x)
from fractions import*
```
[Try it online!](https://tio.run/##TcjLCsIwEEDRfb5ilkkZEFtfFLr1J7SLmDQayIsxQvL10YVKd/fcVPMjhr6Z6dqc9DctoYy06Jda@M9Yx9LVzV1p/mmBRTBD0YMhqbKN4QnWp0i5a266nL@TbxF6gfD3gLBbe49wWPuIcBIzY4lsyGC4E@0N "Python 2 – Try It Online")
[Answer]
## JavaScript (ES6), 85 bytes
```
a=>a.reduce(([b,c],[d,e,g=(b,c)=>c?g(c,b%c):b,h=g(b*e,c*d),i=g(b*d,h)])=>[b*d/i,h/i])
```
Look no builtins! No doubt someone will beat this using a recursive approach or something.
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 30 bytes
This only apply the `lcm` built-in on integers.
```
a->d=denominator(a);lcm(a*d)/d
```
[Try it online!](https://tio.run/##XcxLCoAgFIXheau4Qw3jkvaCqI1Eg0tWCGUi7d8iKMjh@Tj8jrzJVhcW6CBQ1utOz/bYjaXz8Ix4u007o1Rz1MF5Y0@2sEGNnCffyjGvI5ACFBYRKgESmwiL@/kjiWVMb09AiZWA@omECw "Pari/GP – Try It Online")
---
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 3 bytes
This feeds rational numbers to the `lcm` built-in, so it is non-competing.
```
lcm
```
[Try it online!](https://tio.run/##K0gsytRNL/ifpmCr8D8nOfd/QVFmXolGmka0caymJhecZ6hvaI4mYKSjYKxvgiZorKNgpG@BJmgCVIkiZKRvii4EM09HwVTfTEfBHGzIfwA "Pari/GP – Try It Online")
[Answer]
# [Perl 6](https://perl6.org), ~~46~~ 42 bytes
```
{[lcm](@_».numerator)/[gcd] @_».denominator}
```
[test it](https://tio.run/##XZDPboJAEMbvPMUXQ3SpyAoqNhL/XHtq0vQmxiCshgQWskCjsfbFeuuL0V1EDp5m5rcz334zOROJW1cFw5drhZ6WXtAPs4hhWV@3SZjuyGb/92vxKmUiKDNh0O0pjHZoaMR4lsZc8VtdVAdEcZEnwWV0FEFYxhkH@QhUDBLoewNXDdAplpB6EfNUNcYPelS3eziD6DZWsA1Puykfm5IVpWxOYs4KYlgnwXKyfjHkx2GWHgiFHw2xHdCBSnZrUPUkP7REJh0RRwqpxT6ljKdJXxzDRtPTjplo5UcrEPgxz6vShM/OOQtLFuHuVZrwBSuqRNlQVyHfTaehrMcF7m8mHmNmS6z@8yHkSvUbXwAT7b0qFzJoTWlTe34nTfaAjokJnbat1On4xIRDX9uBjk7NZ1mHzjrmPqmamFHXxLzTGc@o8w8 "Perl 6 – Try It Online")
```
{[lcm](($/=@_».nude)[*;0])/[gcd] $/[*;1]}
```
[test it](https://tio.run/##XZBNb4JAEIbv/Io3huiiKyuo2Ej8uPbUpOkNiEFYDQkC4aPRWPvHeusfw11EDp5m5p3ZZ9@ZjOexVVcFx7elB7ZyuqAfpCHHqr46cXDyCFHZarv7/9OTKuSaM7QnnsacYxB6UJkoDe9WF9UeYVRksX8ZH3I/KKM0Afn0ZfRjqDsNVwViHis0HFtWE/yix1SjhzOIamANQ7OVm/SwLXlRiuE4SnhBNP2Y84xshpqwEaSnPWFwwxGcARvIxNuAyZb4UM/TMs2JKUByqS@BsRXhK8GoYdrKIc1b/HgNAjdKsqqkcPk540HJQzy8ChNuzosqljbkRchPM6lJ61GBR4/i@Yy2it5/PYRYqX5PlsBU@ajKpQhKUxrMWDyUJnuKJsWUzdpRZnb6lMJkb@2DTp3RV6zJ5p1mvVAp5syiWHScyZyZdw "Perl 6 – Try It Online")
Input is a list of [Rational](https://docs.perl6.org/type/Rational) numbers.
## Expanded:
```
{ # bare block lambda with implicit parameter list ｢@_｣
  [lcm](            # reduce using &infix:<lcm>
    (
      $/ = @_».nude # store in ｢$/｣ a list of the NUmerators and DEnominiators
                    # ((1,2), (3,4))
    )[
      *;            # from all of the first level ｢*｣,
      0             # but only the 0th of the second level (numerators)
    ]
  )
  /
  [gcd] $/[ *; 1 ]  # gcd of the denominators
}
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 117 bytes
```
\d+
$*
\b(1+)(\1)*/(\1)+\b
$#2$*11/$#3$*
{`^((1+)\2*)/(1+)+ (\2)+/\3+\b
$1 $#4$*1/$3
}`\G1(?=1* (1+))|\G 1+
$1
1+
$.&
```
[Try it online!](https://tio.run/##Hc2xCgIxDMbxPU8RaJCmBUPa83QRx3uJIOehg4vD4ab37LVx@fMNP/jWx/v5urVm9wyUwJaomaMpJ/FmW4BCoaQqFGoXn/ka3VhJLD4yRiucxeofK1IYuheqsM02abycNaFL/tqE2n8UvPtdayoFqwx4kBGPcvoB "Retina – Try It Online") Takes input as a space-separated series of improper fractions (no integers or mixed numbers). Explanation:
```
\d+
$*
```
Converts decimal to unary.
```
\b(1+)(\1)*/(\1)+\b
$#2$*11/$#3$*
```
This reduces each fraction to its lowest terms. Capture group 1 represents the GCD of the numerator and denominator, so we count the number of captures before and after the `/`. `\b(1+)+/(\1)+\b` doesn't seem to count the number of captures correctly for some reason, so I use an extra capturing group and add 1 to the result.
```
{`^((1+)\2*)/(1+)+ (\2)+/\3+\b
$1 $#4$*1/$3
```
This does a number of things. Capture group 2 represents the GCD of the numerators of the first two fractions, while capture group 3 represents the GCD of the denominators. `$#4` is therefore the second numerator divided by their GCD. (Again, I couldn't could the number of captures of the first numerator, but I only need to divide one numerator by their GCD, so it doesn't cost me quite so much.)
```
}`\G1(?=1* (1+))|\G 1+
$1
```
Now that the second numerator has been divided by their GCD, we just use this expression from the unary arithmetic tutorial to multiply the two together, resulting in the LCM. We then repeat the exercise for any remaining fractions.
```
1+
$.&
```
Converts unary back to decimal.
[Answer]
# Common Lisp, 154 bytes
```
(defun f(l &aux(s(pairlis l l)))(loop(and(eval`(=,@(mapcar'car s)))(return(caar s)))(let((x(assoc(reduce'min s :key'car)s)))(rplaca x(+(car x)(cdr x))))))
```
[Algorithm used](https://en.wikipedia.org/wiki/Least_common_multiple#A_simple_algorithm) (specified for integers, but works also for rationals).
First make an associative list of the input data with itself, to get track of the initial values of the elements, so the operating sequence is given by the “car”s of the list.
```
(defun f(l &aux (s (pairlis l l)))        ; make the associative list
  (loop
     (when (eval `(= ,@(mapcar 'car s))) ; when the car are all equal
       (return (caar s)))                 ; exit with the first one
     (let ((x (assoc (reduce 'min s :key 'car) s))) ; find the (first) least element
       (rplaca x (+ (car x) (cdr x))))))  ; replace its car adding the original value (cdr)
```
Test cases:
```
CL-USER> (f '(3))
3
CL-USER> (f '(1/17))
1/17
CL-USER> (f '(1/2 3/4))
3/2
CL-USER> (f '(1/3 2/8))
1
CL-USER> (f '(1/4 3))
3
CL-USER> (f '(2/5 3))
6
CL-USER> (f '(1/2 3/4 5/6 7/8))
105/2
```
Note: The solution is without the use of the builting `lcm` and `gcd`, that accept integers.
[Answer]
# [PHP](https://php.net/), 194 bytes
```
<?for(list($n,$d)=$_GET,$p=array_product($d);$x=$n[+$k];)$r[]=$x*$p/$d[+$k++];for($l=1;$l&&++$i;$l=!$l)foreach($r as$v)$l*=$i%$v<1;for($t=1+$i;$p%--$t||$i%$t;);echo$p/$t>1?$i/$t."/".$p/$t:$i/$t;
```
-4 Bytes with PHP>=7.1 `[$n,$d]=$_GET` instead of `list($n,$d)=$_GET`
[Try it online!](https://tio.run/##JY3NasMwEITveYpUTIIVOwlK@kcVNYdiQi/tJTchjLHdWtTYYqOGFEJf3ZXdw8fuzuzsutr1u72r3XRSEXWUUeU68rb9jH7T7O39@PqScjlBdkiPSmsmWMK2gbvAAzOJZpvQ3QbuA4/MGNl/dBQ19uQjtAlKrsZwAqdyovwnc9SV30VwSy5xUWh1jC8jOUgbhcsCbo1y0OLYyOEWGiUkmvk8jmFDo27Q8GBUeVFHoGl@wpmjWSjYGc478R/ySozrbrZcwl@vg@kll1VRd8ML/yz2sKGu2JqtRuVpnGXf/wE "PHP – Try It Online")
[Answer]
## Common Lisp, ~~87~~ 78 bytes
Using `lcm` and `gcd`, which have integer inputs:
```
(defun l(a)(/(apply #'lcm(mapcar #'numerator a))(apply #'gcd(mapcar #'denominator a))))
```
More golfed:
```
(defun l(a)(eval`(/(lcm,@(mapcar'numerator a))(gcd,@(mapcar'denominator a))))
```
[Answer]
# Mathematica, 3 bytes
```
LCM
```
Mathematica's built-in [`LCM` function](https://reference.wolfram.com/language/ref/LCM.html) is capable of handling rational number inputs.
]