brewersfan1976

max_fraction.rb

Mar 5th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.44 KB | None | 0 0
  1. def maxFraction(numerators, denominators)
  2.     array_length = numerators.length
  3.     x = 0
  4.     largest = 0
  5.     largest_value = 0.0
  6.    
  7.     while (x < array_length)
  8.         if (numerators[x].to_f / denominators[x].to_f) > largest_value then
  9.             largest = x
  10.             largest_value = (numerators[x].to_f / denominators[x].to_f)
  11.         end
  12.            
  13.         x = x + 1
  14.     end
  15.        
  16.     return largest
  17.            
  18. end
Advertisement
Add Comment
Please, Sign In to add comment