Make two numbers co-prime while preserving their least common multiple Given two positive integers a and b, output two positive integers c and d such that:


c divides a
d divides b
c and d are co-prime
the least common multiple of c and d equals the least common multiple of a and b.


If there are more than one possible answers, you can output only one or all of them.

Test cases:

 a  b  c  d
12 18  4  9
18 12  9  4
 5  7  5  7
 3  6  1  6 or 3 2
 9  9  9  1 or 1 9
 6 15  2 15 or 6 5
 1  1  1  1


This is code-golf. Shortest answer in bytes wins.
Jelly, 21 13 bytes
ÆEz®0iṂ$¦€ZÆẸ

Try it online!

If a = 2A · 3B · 5C · … and b = 2α · 3β · 5γ · …, then we compute

c = 2A&gt;α?A:0 · 3B&gt;β?B:0 · 5C&gt;γ?C:0 · …

d = 2A&gt;α?0:α · 3B&gt;β?0:β · 5C&gt;γ?0:γ · …


Now lcm(c, d) = 2max(A&gt;α?A:0, A&gt;α?0:α) · … = 2max(A, α) · 3max(B, β) · … = lcm(a, b)
and gcd(c, d) = 2min(A&gt;α?A:0, A&gt;α?0:α) · … = 20 · 30 · 50 · … = 1.

In other words: start from (c, d) = (a, b). Then, for each prime, divide that prime all the way out of the factorization of either c or d: whichever has the smallest exponent for that prime. (In this implementation, in case of a tie, c loses its exponent.)
So if a = 2250 = 21 · 32 · 53 and b = 360 = 23 · 32 · 51,
then c = 20 · 30 · 53 = 125 and d = 23 · 32 · 50 = 72.
Jonathan Allan golfed down a whopping 8 bytes! Thank you~