GCD / LCM Polyglots! Your challenge is to make a program or function that outputs the GCD of its inputs in one language and the LCM of its inputs in another. Builtins for GCD or LCM (I'm looking at you, Mathematica) are allowed but not encouraged. There will be 2 inputs, which will always be positive integers, never greater than 1000.

Test Cases

Each line is one test case in the format x y =&gt; GCD(x,y) LCM(x,y):

1 1 =&gt; 1 1
1 2 =&gt; 1 2
4 1 =&gt; 1 4
3 4 =&gt; 1 12
7 5 =&gt; 1 35
18 15 =&gt; 3 90
23 23 =&gt; 23 23
999 1000 =&gt; 1 999000
1000 999 =&gt; 1 999000
1000 1000 =&gt; 1000 1000


See this pastebin for all possible inputs with 0 &lt; x, y &lt; 31. Note that different versions of the same languages count as different languages.
C / C++, 79 78 73 bytes

Thanks to @ETHproductions for saving a byte!

int f(int a,int b){int c,d=a*b;for(;a;b=c)c=a,a=b%a;auto e=.5;c=e?d/b:b;}


C calculates the GCD: Try it online!

C++ calculates the LCM: Try it online!

In C, auto e=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

The function calculates the GCD with Euclid's algorithm, and the LCM by dividing the product of a and b by the GCD.

Omitting the return statement works at least on GCC. The 78 byte solution below should work with any compiler:

int f(int a,int b){int c,d=a*b;for(;a;b=c)c=a,a=b%a;auto e=.5;return e?d/b:b;}