brewersfan1976

rightmost_round_number.rb

Feb 27th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.39 KB | None | 0 0
  1. def rightmostRoundNumber(inputArray)
  2.     x = 0
  3.     array_length = inputArray.length
  4.     number = 0
  5.     found = false
  6.    
  7.     while (x < array_length)
  8.         if inputArray[x] % 10 == 0 then
  9.            number = x
  10.            found = true
  11.         end
  12.            
  13.         x = x + 1
  14.     end
  15.        
  16.     if found == true then
  17.        return number
  18.     else
  19.        return -1
  20.     end
  21.  end
Advertisement
Add Comment
Please, Sign In to add comment