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

deleted 45 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

If built-ins weren't forbidden, g (1 byte, built-in GCD) and ×ばつ÷æl (4 bytes, product divided by LCM) would achieve a better score.

How it works

ṛß%ðḷṛ? Main link. Arguments: a, b
 ð Convert the chain to the left into a link; start a new, dyadic chain.
 ß Recursively call the main link...
ṛ % with b and a % b as arguments.
 ṛ? If the right argument (b) is non-zero, execute the link.
 ḷ Else, yield the left argument (a).

Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

If built-ins weren't forbidden, g (1 byte, built-in GCD) and ×ばつ÷æl (4 bytes, product divided by LCM) would achieve a better score.

How it works

ṛß%ðḷṛ? Main link. Arguments: a, b
 ð Convert the chain to the left into a link; start a new, dyadic chain.
 ß Recursively call the main link...
ṛ % with b and a % b as arguments.
 ṛ? If the right argument (b) is non-zero, execute the link.
 ḷ Else, yield the left argument (a).

Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

If built-ins weren't forbidden, g (1 byte, built-in GCD) would achieve a better score.

How it works

ṛß%ðḷṛ? Main link. Arguments: a, b
 ð Convert the chain to the left into a link; start a new, dyadic chain.
 ß Recursively call the main link...
ṛ % with b and a % b as arguments.
 ṛ? If the right argument (b) is non-zero, execute the link.
 ḷ Else, yield the left argument (a).
added 374 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 1 byte

g

Try it online!


Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

If built-ins weren't forbidden, g (1 byte, built-in GCD) and ×ばつ÷æl (4 bytes, product divided by LCM) would achieve a better score.

How it works

ṛß%ðḷṛ? Main link. Arguments: a, b
 ð Convert the chain to the left into a link; start a new, dyadic chain.
 ß Recursively call the main link...
ṛ % with b and a % b as arguments.
 ṛ? If the right argument (b) is non-zero, execute the link.
 ḷ Else, yield the left argument (a).

Jelly, 1 byte

g

Try it online!


Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

If built-ins weren't forbidden, g (1 byte, built-in GCD) and ×ばつ÷æl (4 bytes, product divided by LCM) would achieve a better score.

How it works

ṛß%ðḷṛ? Main link. Arguments: a, b
 ð Convert the chain to the left into a link; start a new, dyadic chain.
 ß Recursively call the main link...
ṛ % with b and a % b as arguments.
 ṛ? If the right argument (b) is non-zero, execute the link.
 ḷ Else, yield the left argument (a).
added 202 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 1 byte

g

Try it online!


Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

Jelly, 1 byte

g

Try it online!

Jelly, 1 byte

g

Try it online!


Jelly, 7 bytes

ṛß%ðḷṛ?

Recursive implementation of the Euclidean algorithm. Try it online!

Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading

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