Count of elements on the left which are divisible by current element | Utility function to print the elements of the array ; Function to generate and print the required array ; For every element of the array ; To store the count of elements on the left that the current element divides ; Print the generated array ; Driver code
def printArr ( arr , n ) : NEW_LINE INDENT for i in arr : NEW_LINE INDENT print ( i , end = " ▁ " ) NEW_LINE DEDENT DEDENT def generateArr ( A , n ) : NEW_LINE INDENT B = [ 0 for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT cnt = 0 NEW_LINE for j in range ( i ) : NEW_LINE INDENT if ( A [ j ] % A [ i ] == 0 ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT B [ i ] = cnt NEW_LINE DEDENT printArr ( B , n ) NEW_LINE DEDENT A = [ 3 , 5 , 1 ] NEW_LINE n = len ( A ) NEW_LINE generateArr ( A , n ) NEW_LINE