brewersfan1976

fraction_multiplication.rb

Aug 14th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.25 KB | None | 0 0
  1. def fractionMultiplication(a, b)
  2.     output_array = Array.new
  3.     top = a[0] * b[0]
  4.     bottom = a[1] * b[1]
  5.     divisor = top.gcd(bottom)
  6.     output_array[0] = top / divisor
  7.     output_array[1] = bottom / divisor
  8.    
  9.     return output_array
  10. end
Advertisement
Add Comment
Please, Sign In to add comment