human
Count of elements on the left which are divisible by current element | Set 2 | Utility function to prthe elements of the array.
Function to increment the count for each factor of given val.
Function to generate and print the required array.
Find max element of arr.
Create count array of maxi size.
For every element of the array.
Count [ A [ i ] ] denotes how many previous elements are there whose factor is the current element ..
Increment in count array for factors of A [ i ].
Print the generated array.
Driver code"
Solution in Python:
 Can you provide a code to count of elements on the left which are divisible by current element and the other steps required?
assistant
#Here is code to count of elements on the left which are divisible by current element and the other steps required.
 def printArr ( arr , n ) :
	for i in range ( n ) :
		print ( arr [ i ] , end = " ▁ " )
def IncrementFactors ( count , val ) :
	i = 1
	while ( i * i <= val ) :
		if ( val % i == 0 ) :
			if ( i == val // i ) :
				count [ i ] += 1
			else :
				count [ i ] += 1
				count [ val // i ] += 1
		i += 1
def generateArr ( A , n ) :
	B = [ 0 ] * n
	maxi = max ( A )
	count = [ 0 ] * ( maxi + 1 )
	for i in range ( n ) :
		B [ i ] = count [ A [ i ] ]
		IncrementFactors ( count , A [ i ] )
	printArr ( B , n )
arr = [ 8 , 1 , 28 , 4 , 2 , 6 , 7 ]
n = len ( arr )
generateArr ( arr , n )