Skip to content

Conversation

@orionlibs
Copy link
Contributor

@orionlibs orionlibs commented Jul 13, 2023

NUMBER-194. Overloaded method that determines if 2 integers are relatively prime or coprime. Included tests

@aherbert
Copy link
Contributor

These are simply pass through methods for ArithmeticUtils.gcd where gcd == 1.

The new methods do not include a link to gcd and also lose all the javadoc on the special cases for that method, including exception cases. Adding these methods brings in the dependency on the core module and bloats the primes module. I believe it better to add javadoc to the Primes class to sign post users to ArithmeticUtils, e.g. in the class javadoc:

 * <p>Additional methods for integer arithmetic can be found in the Numbers core module in
 * {@code o.a.c.numbers.core.ArithmeticUtils}. This includes a method to obtain the
 * greatest common divisor (GCD) of two integers which can be used to determine if two numbers
 * are relatively prime.

Thus users can bring in that dependency if they require.

@orionlibs orionlibs changed the title [NUMBERS]: implemented method that determines if 2 integers are relat… [NUMB-194]: method that determines if 2 integers are coprime Jul 13, 2023
@orionlibs
Copy link
Contributor Author

orionlibs commented Jul 13, 2023

These are simply pass through methods for ArithmeticUtils.gcd where gcd == 1.

The new methods do not include a link to gcd and also lose all the javadoc on the special cases for that method, including exception cases. Adding these methods brings in the dependency on the core module and bloats the primes module. I believe it better to add javadoc to the Primes class to sign post users to ArithmeticUtils, e.g. in the class javadoc:

 * <p>Additional methods for integer arithmetic can be found in the Numbers core module in
 * {@code o.a.c.numbers.core.ArithmeticUtils}. This includes a method to obtain the
 * greatest common divisor (GCD) of two integers which can be used to determine if two numbers
 * are relatively prime.

Thus users can bring in that dependency if they require.

@aherbert hello. I am sorry, but how can I implement the function using ArithmeticUtils::gcd without importing the core module? What is the procedure in such cases? Mathematics is very very interconnected. Every mathematical object can use every other. You can have a set of vectors or a vector of sets, etc. Math modules will eventually have to be interconnected

@aherbert
Copy link
Contributor

I was stating that this entire PR should be dropped and replaced with some better documentation in the Primes class header to indicate that the functionality to detect relatively prime numbers can be found in ArithmeticUtils.

@orionlibs
Copy link
Contributor Author

orionlibs commented Jul 13, 2023

I was stating that this entire PR should be dropped and replaced with some better documentation in the Primes class header to indicate that the functionality to detect relatively prime numbers can be found in ArithmeticUtils.

@aherbert not every dev knows that checking for coprimes requires a GCD calculation, but they do know that coprimes require some kind of primes utility since coprime has "prime" in its name. You know? So, they will use the Primes class to see what kinds of methods it has. It will not occur to them to go to the ArithmeticUtils to check specifically the GCD method JavaDoc. I can add your suggested JavaDoc to the GCD methods, if you want, but.............

@orionlibs orionlibs closed this Jul 13, 2023
@orionlibs orionlibs deleted the NUMB-new-areRelativePrimes-method branch July 13, 2023 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants