Advertisement
Guest User

Untitled

a guest
Feb 27th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.61 KB | None | 0 0
  1. # Write a method, coprime?(num_1, num_2), that accepts two numbers as args.
  2. # The method should return true if the only common divisor between the two numbers is 1.
  3. # The method should return false otherwise. For example coprime?(25, 12) is true because
  4. # 1 is the only number that divides both 25 and 12.
  5.  
  6.  
  7. p coprime?(25, 12)    # => true
  8. p coprime?(7, 11)     # => true
  9. p coprime?(30, 9)     # => false
  10. p coprime?(6, 24)     # => false
  11.  
  12. def coprime(numberOne, numberTwo) {
  13.     2..numberOne-1.do |divisor|
  14.         if (divisor / numberTwo) == 0
  15.             return false;
  16.         end
  17.     end
  18. return true;
  19. end
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement