Relatively prime integers in NumPy

Popov, Dmitry Yu dpopov at anl.gov
Mon Jul 8 15:09:45 EDT 2024


Dear Sirs.

Does NumPy provide a simple mechanism to identify relatively prime integers, i.e. integers which don't have a common factor other than +1 or -1? For example, in case of this array:
[[1,5,8],
  [2,4,8],
  [3,3,9]]
I can imagine a function which would return array of common factors along axis 0: [1,2,3]. Those triples of numbers along axis 1 with the factor of1 or -1 would be relatively prime integers.

Regards,
Dmitry Popov

Argonne, IL
USA



More information about the Python-list mailing list