Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def leastCommonPrimeDivisor(a, b)
- require 'prime'
- if a < b then
- min = a
- else
- min = b
- end
- x = 2
- while (x <= min)
- if x.prime? == true and a % x == 0 and b % x == 0 then
- return x
- end
- x = x + 1
- end
- return -1
- end
Advertisement
Add Comment
Please, Sign In to add comment