Generate an array having sum of Euler Totient Function of all elements equal to N | Python3 program for the above approach ; Function to construct the array such the sum of values of Euler Totient functions of all array elements is N ; Stores the resultant array ; Find divisors in sqrt ( N ) ; If N is divisible by i ; Push the current divisor ; If N is not a perfect square ; Push the second divisor ; Print the resultant array ; Driver Code ; Function Call
from math import sqrt NEW_LINE def constructArray ( N ) : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( 1 , int ( sqrt ( N ) ) + 1 , 1 ) : NEW_LINE INDENT if ( N % i == 0 ) : NEW_LINE INDENT ans . append ( i ) NEW_LINE if ( N != ( i * i ) ) : NEW_LINE INDENT ans . append ( N / i ) NEW_LINE DEDENT DEDENT DEDENT for it in ans : NEW_LINE INDENT print ( int ( it ) , end = " ▁ " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 12 NEW_LINE constructArray ( N ) NEW_LINE DEDENT