Sha256: 408144bd139d4ff4b1d3b29f340e72aec7826fc0151ac1dbac5108a5678806f0

Contents?: true

Size: 224 Bytes

Versions: 86

Compression:

Stored size: 224 Bytes

Contents

#!/usr/bin/env ruby

# GCD. We assume positive numbers
def gcd(a, b)
  # Make: a <= b
  if a > b
    a, b = [b, a]
  end

  return nil if a <= 0

  if a == 1 or b-a == 0
    return a
  end
  return gcd(b-a, a)
end

gcd(3,5)

Version data entries

86 entries across 75 versions & 8 rubygems

Version Path
debase-0.2.7 test/example/gcd.rb
debase-0.2.6 test/example/gcd.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/debase-0.2.5.beta2/test/example/gcd.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/debase-0.2.5.beta1/test/example/gcd.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/debase-0.2.5.beta1/test/example/gcd.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/debase-0.2.4.1/test/example/gcd.rb
debase-0.2.5.beta2 test/example/gcd.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/debase-0.2.4.1/test/example/gcd.rb