brewersfan1976

apples_distribution.rb

Mar 7th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.30 KB | None | 0 0
  1. def applesDistribution(apples, boxCapacity, maxResidue)
  2.     x = 1
  3.     number = 0
  4.    
  5.     while (x <= boxCapacity)
  6.         if apples % x == 0 or (apples - maxResidue) % x == 0 then
  7.            number = number + 1
  8.         end
  9.            
  10.         x = x + 1
  11.     end
  12.        
  13.     return number
  14. end
Advertisement
Add Comment
Please, Sign In to add comment