human
Maximum number with same digit factorial product | Function to return the required number.
Count the frequency of each digit.
4 ! can be expressed as 2 ! * 2 ! * 3 !.
6 ! can be expressed as 5 ! * 3 !.
8 ! can be expressed as 7 ! * 2 ! * 2 ! * 2 !.
9 ! can be expressed as 7 ! * 3 ! * 3 ! * 2 !.
To store the required number.
If number has only either 1 and 0 as its digits.
Generate the greatest number possible.
Driver code"
Solution in Python:
assistant
#Here is code to maximum number with same digit factorial product and the other steps required.
 def getNumber ( s ) :
	number_of_digits = len ( s ) ;
	freq = [ 0 ] * 10 ;
	for i in range ( number_of_digits ) :
		if ( s [ i ] == '1' or s [ i ] == '2' or s [ i ] == '3' or s [ i ] == '5' or s [ i ] == '7' ) :
			freq [ ord ( s [ i ] ) - 48 ] += 1 ;
		if ( s [ i ] == '4' ) :
			freq [ 2 ] += 2 ;
			freq [ 3 ] += 1 ;
		if ( s [ i ] == '6' ) :
			freq [ 5 ] += 1 ;
			freq [ 3 ] += 1 ;
		if ( s [ i ] == '8' ) :
			freq [ 7 ] += 1 ;
			freq [ 2 ] += 3 ;
		if ( s [ i ] == '9' ) :
			freq [ 7 ] += 1 ;
			freq [ 3 ] += 2 ;
			freq [ 2 ] += 1 ;
	t = " " ;
	if ( freq [ 1 ] == number_of_digits or freq [ 0 ] == number_of_digits or ( freq [ 0 ] + freq [ 1 ] ) == number_of_digits ) :
		return s ;
	else :
		for i in range ( 9 , 1 , - 1 ) :
			ctr = freq [ i ] ;
			while ( ctr > 0 ) :
				t += chr ( i + 48 ) ;
				ctr -= 1 ;
		return t ;
s = "1280" ;
print ( getNumber ( s ) ) ;