Sha256: 23ab8d50d2d4888b0809bf72505536e9143a80cc7ec845336c05b37e7ab601a3
Contents?: true
Size: 319 Bytes
Versions: 1
Compression:
Stored size: 319 Bytes
Contents
#!/usr/bin/env ruby # GCD. We assume positive numbers def gcd(a, b) # Make: a <= b debugger 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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trepanning-0.1.3 | test/example/gcd.rb |