human
Find the n | function to find nth number made of even digits only.
If n = 1 return 0.
vector to store the digits when converted into base 5.
Reduce n to n - 1 to exclude 0.
Reduce n to base 5 number and store digits.
pushing the digits into vector.
variable to represent the number after converting it to base 5. Since the digits are be in reverse order , we traverse vector from back.
return 2 * result ( to convert digits 0 , 1 , 2 , 3 , 4 to 0 , 2 , 4 , 6 , 8..
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to find the n and the other steps required.
 def findNthEvenDigitNumber ( n ) :
	if ( n == 1 ) :
		return 0
	v = [ ]
	n = n - 1
	while ( n > 0 ) :
		v . append ( n % 5 )
		n = n // 5
	result = 0
	for i in range ( len ( v ) - 1 , - 1 , - 1 ) :
		result = result * 10
		result = result + v [ i ]
	return 2 * result
if __name__ == " _ _ main _ _ " :
	print ( findNthEvenDigitNumber ( 2 ) )
	print ( findNthEvenDigitNumber ( 10 ) )