-
-
Save RickArora/8de9e0d08b94392615094fd9d92a0fff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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