Sha256: 2662dd9d91bd0324b682d14b91efc6b4e12aaa5693e4f7435bb3505a565e63f2

Contents?: true

Size: 277 Bytes

Versions: 17

Compression:

Stored size: 277 Bytes

Contents

# 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
  addline

  if a == 1 or b-a == 0
    return a
  end
end

a, b = ARGV[0..1].map {|arg| arg.to_i}
puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
trepanning-2.15.35 test/example/gcd-xx.rb
trepanning-1.93.35 test/example/gcd-xx.rb
trepanning-2.15.33 test/example/gcd-xx.rb
trepanning-1.93.32 test/example/gcd-xx.rb
trepanning-0.1.6 test/example/gcd-xx.rb
trepanning-0.1.4 test/example/gcd-xx.rb
trepanning-0.1.3 test/example/gcd-xx.rb
trepanning-0.1.2 test/example/gcd-xx.rb
trepanning-0.1.1 test/example/gcd-xx.rb
trepanning-0.1.0 test/example/gcd-xx.rb
rbx-trepanning-0.0.3-universal-rubinius-1.2 test/example/gcd-xx.rb
rbx-trepanning-0.0.2-universal-rubinius-1.2 test/example/gcd-xx.rb
rbx-trepanning-0.0.1-universal-rubinius test/example/gcd-xx.rb
trepanning-0.0.9 test/example/gcd-xx.rb
trepanning-0.0.8 test/example/gcd-xx.rb
trepanning-0.0.6 test/example/gcd-xx.rb
trepanning-0.0.4 test/example/gcd-xx.rb