# Print all numbers that are divisors of N and are co-prime with the quotient of their division

Print all numbers that are divisors of N and are co-prime with the quotient of their divisionGiven a positive integer N, the task is to print all the numbers, say K, such that K is a divisor of N and K and N / K are coprime.Examples:Input: N = 12  Output: 1 3 4 12  Explanation:All numbers K such that it is divisor of N(= 12) and K and N/K are coprime:1: Since 1 is a divisor of 12 and 1 and 12(= 12/1) are coprime.3: Since 3 is a divisor of 12 and 3 and 4( = 12/3) are coprime.4: Since 4 is a divisor of 12 and 4 and 3( = 12/4) are coprime.12: Since 12 is a divisor of 12 and 12 and 1( = 12/12) are coprime.Input: N = 100  Output: 1 4 25 100Naive Approach: The simplest approach to solve the given problem is to iterate over the range [1, N] and check for each number K whether K is a divisor of N and GCD of K and N/K is 1 or not. If found to be true, then print K. Otherwise, check for the next number.Time Complexity: O(N*log N)Auxiliary Space: O(1)Efficient Approach: The above approach can also be optimized by using the observation that all the divisors are present in pairs. For Example, if N is 100, then all the pairs of divisors are: (1, 100), (2, 50), (4, 25), (5, 20), (10, 10).Therefore, the idea is to iterate in the range [1, √N] and check if both the given conditions are satisfied or not i.e., whether any number K is a divisor of N and GCD of K and N/K is 1 or not. If found to be true, then print both the numbers. In the case of two equal divisors, print only one of them.Below is the implementation of the above approach:  C++  #include using namespace std;  void printUnitaryDivisors(int n){        for (int i = 1; i