Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Write a method, coprime?(num_1, num_2), that accepts two numbers as args.
- # The method should return true if the only common divisor between the two numbers is 1.
- # The method should return false otherwise. For example coprime?(25, 12) is true because
- # 1 is the only number that divides both 25 and 12.
- p coprime?(25, 12) # => true
- p coprime?(7, 11) # => true
- p coprime?(30, 9) # => false
- p coprime?(6, 24) # => false
- def coprime(numberOne, numberTwo) {
- 2..numberOne-1.do |divisor|
- if (divisor / numberTwo) == 0
- return false;
- end
- end
- return true;
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement