Generate an array having sum of Euler Totient Function of all elements equal to N

Generate an array having sum of Euler Totient Function of all elements equal to N
Given a positive integer N, the task is to generate an array such that the sum of Euler Totient Function of each element is equal to N.
Examples:

Input: N = 6Output: 3 8Explanation:The total number of integers i, from 1 to 3 such that GCD(i, 3) = 1 is 2.The total number of integers i, from 1 to 6 such that GCD(i, 6) = 1 is 4.After the above operations, the required array whose sum is 6 is {3, 8}.
Input: N = 12Output: 1 12 2 6 3 4

Approach: The given problem can be solved based on the divisor sum property of the Euler Totient Function, i.e.,Below is the implementation of the above approach:

C++

#include
using namespace std;

void constructArray(int N)
{
    
    vector ans;

    
    for (int i = 1; i * i