


"""simple docstring"""





def    _snake_case  (  _snake_case :	int	):

      # bit count represents no. of bits in the gray code
      if bit_count < 0:
            raise ValueError('''The given input must be positive'''	)

      # get the generated string sequence
      lowerCAmelCase    :		Optional[int]				=      gray_code_sequence_string(_snake_case	)
      #
      # convert them to integers
      for i in range(len(_snake_case	)	):
            lowerCAmelCase    :		Any				=      int(sequence[i]       ,      2	)

      return sequence


def    _snake_case  (  _snake_case :	int	):

      # The approach is a recursive one
      # Base case achieved when either n = 0 or n=1
      if bit_count == 0:
            return ["0"]

      if bit_count == 1:
            return ["0", "1"]

      lowerCAmelCase    :		int				=      1 << bit_count  # defines the length of the sequence
      # 1<< n is equivalent to 2^n

      # recursive answer will generate answer for n-1 bits
      lowerCAmelCase    :		List[Any]				=      gray_code_sequence_string(bit_count - 1	)

      lowerCAmelCase    :		int				=      []

      # append 0 to first half of the smaller sequence generated
      for i in range(seq_len // 2	):
            lowerCAmelCase    :		str				=      '''0''' + smaller_sequence[i]
            sequence.append(_snake_case	)

      # append 1 to second half ... start from the end of the list
      for i in reversed(range(seq_len // 2	)	):
            lowerCAmelCase    :		int				=      '''1''' + smaller_sequence[i]
            sequence.append(_snake_case	)

      return sequence


if __name__ == "__main__":
 import doctest

 doctest.testmod()






def       lowercase_		(		_A			:    int    ,					_A			:    int						):

      """simple docstring"""




      while a != 0:
            lowerCamelCase__    ,   lowerCamelCase__		:				Optional[Any]    =  b % a, a
      return b


def       lowercase_		(		_A			:    int    ,					_A			:    int						):

      """simple docstring"""




      if gcd(_A    ,					_A						) != 1:
            lowerCamelCase__		:				List[str]    =  F"mod inverse of {a!r} and {m!r} does not exist"
            raise ValueError(_A						)
      lowerCamelCase__    ,   lowerCamelCase__    ,   lowerCamelCase__		:				Tuple    =  1, 0, a
      lowerCamelCase__    ,   lowerCamelCase__    ,   lowerCamelCase__		:				Optional[int]    =  0, 1, m
      while va != 0:
            lowerCamelCase__		:				Tuple    =  ua // va
            lowerCamelCase__    ,   lowerCamelCase__    ,   lowerCamelCase__    ,   lowerCamelCase__    ,   lowerCamelCase__    ,   lowerCamelCase__		:				str    =  (ua - q * va), (ua - q * va), (ua - q * va), va, va, va
      return ua % m


