brewersfan1976

house_number.rb

Feb 25th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.32 KB | None | 0 0
  1. def houseNumbersSum(inputArray)
  2.     array_length = inputArray.length
  3.     x = 0
  4.     total = 0
  5.    
  6.     while (x <= array_length)
  7.         if inputArray[x] != 0 then
  8.            total = total + inputArray[x]
  9.         else
  10.             break
  11.         end
  12.            
  13.         x = x + 1
  14.      end
  15.        
  16.      return total
  17. end
Advertisement
Add Comment
Please, Sign In to add comment