Slick. I didn't use ruby-google because I didn't want to take the time to apply for an API key :)
Now you don't have to, I just posted mine to the mailing list ;).
Can you explain the math to me or point me some place that does?
This time, with comments: # Euclid's 'algorithm' for finding # the greatest common divisor implemented # using tail-recursion. This is arguably # the oldest algorithm. # # http://en.wikipedia.org/wiki/Euclidean_algorithm # # ex: # gcd(1071,1029) = gcd(1029,42) = gcd(42,21) = gcd(21,0) = 21 def gcd(a,b) b == 0 ? a : gcd(b, a % b) end # Takes two numbers, finds their greatest # common divisor and divides both by it # then returns a string representing the # reduced fraction in the form "a:b". def ratio(a,b) # Don't want do divide by zero! return "0" if a == 0 or b == 0 # Get the GCD d = gcd(a,b) # Do integer division and print the formatted result "#{a/d}:#{b/d}" end -- Caleb Phillips IT Specialist Small White Cube _______________________________________________ PDXRuby mailing list [email protected] IRC: #pdx.rb on irc.freenode.net http://lists.pdxruby.org/mailman/listinfo/pdxruby
