Skip to content

Instantly share code, notes, and snippets.

View gpfeiffer's full-sized avatar
👷‍♂️
under construction

Götz Pfeiffer gpfeiffer

👷‍♂️
under construction
  • NUI Galway
  • Galway, Ireland
View GitHub Profile
@gpfeiffer
gpfeiffer / extended_gcd.rb
Last active January 29, 2022 14:16
Extended Euclidean Algorithm in Ruby
#############################################################################
##
## extended_gcd.rb
##
## given non-negative integers a > b, compute
## coefficients s, t such that gcd(a, b) == s*a + t*b
##
def extended_gcd(a, b)
# trivial case first: gcd(a, 0) == 1*a + 0*0