Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#MATL, 7 bytes

MATL, 7 bytes

pG1$Zm/

Try it Online!

Explanation

Since we can't explicitly use the builtin GCD function (Zd in MATL), I have exploited the fact that the least common multiple of a and b times the greatest common denominator of a and b is equal to the product of a and b.

p % Grab the input implicitly and multiply the two elements
G % Grab the input again, explicitly this time
1$Zm % Compute the least-common multiple
/ % Divide the two to get the greatest common denominator

#MATL, 7 bytes

pG1$Zm/

Try it Online!

Explanation

Since we can't explicitly use the builtin GCD function (Zd in MATL), I have exploited the fact that the least common multiple of a and b times the greatest common denominator of a and b is equal to the product of a and b.

p % Grab the input implicitly and multiply the two elements
G % Grab the input again, explicitly this time
1$Zm % Compute the least-common multiple
/ % Divide the two to get the greatest common denominator

MATL, 7 bytes

pG1$Zm/

Try it Online!

Explanation

Since we can't explicitly use the builtin GCD function (Zd in MATL), I have exploited the fact that the least common multiple of a and b times the greatest common denominator of a and b is equal to the product of a and b.

p % Grab the input implicitly and multiply the two elements
G % Grab the input again, explicitly this time
1$Zm % Compute the least-common multiple
/ % Divide the two to get the greatest common denominator
added 27 characters in body
Source Link
Suever
  • 11.2k
  • 1
  • 24
  • 52

#MATL, 7 bytes

pG1$Zm/

Try it Online!

Explanation

Since we can't explicitly use the builtin GCD function (Zd in MATL), I have exploited the fact that the least common multiple of a and b times the greatest common denominator of a and b is equal to the product of the two inputsa and b.

p % Grab the input implicitly and multiply the two elements
G % Grab the input again, explicitly this time
1$Zm % Compute the least-common multiple
/ % Divide the two to get the greatest common denominator

#MATL, 7 bytes

pG1$Zm/

Try it Online!

Explanation

Since we can't explicitly use the builtin GCD function (Zd in MATL), I have exploited the fact that the least common multiple times the greatest common denominator is equal to the product of the two inputs.

p % Grab the input implicitly and multiply the two elements
G % Grab the input again, explicitly this time
1$Zm % Compute the least-common multiple
/ % Divide the two to get the greatest common denominator

#MATL, 7 bytes

pG1$Zm/

Try it Online!

Explanation

Since we can't explicitly use the builtin GCD function (Zd in MATL), I have exploited the fact that the least common multiple of a and b times the greatest common denominator of a and b is equal to the product of a and b.

p % Grab the input implicitly and multiply the two elements
G % Grab the input again, explicitly this time
1$Zm % Compute the least-common multiple
/ % Divide the two to get the greatest common denominator
Source Link
Suever
  • 11.2k
  • 1
  • 24
  • 52

#MATL, 7 bytes

pG1$Zm/

Try it Online!

Explanation

Since we can't explicitly use the builtin GCD function (Zd in MATL), I have exploited the fact that the least common multiple times the greatest common denominator is equal to the product of the two inputs.

p % Grab the input implicitly and multiply the two elements
G % Grab the input again, explicitly this time
1$Zm % Compute the least-common multiple
/ % Divide the two to get the greatest common denominator

AltStyle によって変換されたページ (->オリジナル) /