Skip to content

Instantly share code, notes, and snippets.

@RickArora
Created February 28, 2019 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RickArora/8de9e0d08b94392615094fd9d92a0fff to your computer and use it in GitHub Desktop.
Save RickArora/8de9e0d08b94392615094fd9d92a0fff to your computer and use it in GitHub Desktop.
# 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment