human
Write me a code to count natural numbers whose all permutation are greater than that number and the other steps required given the following:
Count natural numbers whose all permutation are greater than that number | Return the count of the number having all permutation greater than or equal to the number ..
Pushing 1 to 9 because all number from 1 to 9 have this property ..
take a number from stack and add a digit smaller than last digit of it ..
Driver Code"
Solution in Python:
assistant
#Here is code to count natural numbers whose all permutation are greater than that number and the other steps required.
 def countNumber ( n ) :
	result = 0
	s = [ ]
	for i in range ( 1 , 10 ) :
		if ( i <= n ) :
			s . append ( i )
			result += 1
		while len ( s ) != 0 :
			tp = s [ - 1 ]
			s . pop ( )
			for j in range ( tp % 10 , 10 ) :
				x = tp * 10 + j
				if ( x <= n ) :
					s . append ( x )
					result += 1
	return result
if __name__ == ' _ _ main _ _ ' :
	n = 15
	print ( countNumber ( n ) )