![]() |
VOOZH | about |
Given a positive integer N, the task is to generate an array such that the sum of the Euler Totient Function of each element is equal to N.
Examples:
Input: N = 6
Output: 1 6 2 3Input: N = 12
Output: 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:
1 12 2 6 3 4
Time Complexity: O(√N)
Auxiliary Space: O(N)