Find the Kth position element of the given sequence | Function to return the kth number from the required sequence ; Count of odd integers in the sequence ; kth number is even ; It is odd ; Driver code
def kthNum ( n , k ) : NEW_LINE INDENT a = ( n + 1 ) // 2 ; NEW_LINE if ( k > a ) : NEW_LINE INDENT return ( 2 * ( k - a ) ) ; NEW_LINE DEDENT return ( 2 * k - 1 ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 7 ; k = 7 ; NEW_LINE print ( kthNum ( n , k ) ) ; NEW_LINE DEDENT