What's the logic behind this part of code?

Here is the problem:

Here are the most visible solutions with same logic used everywhere. I don’t understand why this logic is getting AC.

Editorial here

Also it’s editorial code was difficult to grasp. Can anyone explain the logic used in editorial as well? Thanks

Find all the Fctors of the number…
Ex 20-
1-20
2-10
4-5
These are the 4 possible…the Factor will both co-primes or the pair of factors with gcd one will be the answer​:slightly_smiling_face::slightly_smiling_face: