brewersfan1976

fraction_sum.rb

Sep 5th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.25 KB | None | 0 0
  1. def fractionSum(a, b)
  2.     array = Array.new
  3.    
  4.     first = Rational(a[0],a[1])
  5.     second = Rational(b[0], b[1])
  6.     result = first + second
  7.    
  8.     array[0] = result.numerator
  9.     array[1] = result.denominator
  10.    
  11.     return array
  12. end
Advertisement
Add Comment
Please, Sign In to add comment