brewersfan1976

smallest_multiple.rb

Mar 8th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.45 KB | None | 0 0
  1. def smallestMultiple(left, right)
  2.     x = left
  3.     y = left
  4.     divisible = false
  5.    
  6.     while(1)
  7.       while (x <= right)
  8.           if y % x == 0 then
  9.              divisible = true
  10.           else
  11.              divisible = false
  12.              break
  13.           end
  14.            
  15.           x = x + 1
  16.       end
  17.      
  18.       if divisible == true then
  19.         return y
  20.       end
  21.        
  22.       x = left
  23.       y = y + 1    
  24.    end    
  25. end
Advertisement
Add Comment
Please, Sign In to add comment