
from __future__ import annotations





def 							_lowerCamelCase			(					lowerCamelCase_:  int				,	lowerCamelCase_:  int				,	lowerCamelCase_:  int		):



				'''simple docstring'''







				assert n > 1 and a > 0 and greatest_common_divisor(lowerCamelCase_				,	lowerCamelCase_		) == 1
				((A) ,       (A) ,       (A))     :  str   =				extended_gcd(lowerCamelCase_				,	lowerCamelCase_		)  # Implemented below
				A     :  List[str]   =				(b * s) % n
				return x





def 							_lowerCamelCase			(					lowerCamelCase_:  int				,	lowerCamelCase_:  int		):



				'''simple docstring'''







				((A) ,       (A))     :  Any   =				extended_euclid(lowerCamelCase_				,	lowerCamelCase_		)  # Implemented below
				if b < 0:
								A     :  List[Any]   =				(b % n + n) % n
				return b





def 							_lowerCamelCase			(					lowerCamelCase_:  int				,	lowerCamelCase_:  int				,	lowerCamelCase_:  int		):



				'''simple docstring'''







				A     :  Any   =				invert_modulo(lowerCamelCase_				,	lowerCamelCase_		)
				A     :  Optional[int]   =				(b * s) % n
				return x





def 							_lowerCamelCase			(					lowerCamelCase_:  int				,	lowerCamelCase_:  int		):



				'''simple docstring'''







				assert a >= 0 and b >= 0

				if b == 0:
								A ,       A ,       A     :  str   =				a, 1, 0
				else:
								((A) ,       (A) ,       (A))     :  Optional[Any]   =				extended_gcd(lowerCamelCase_				,	a % b		)
								A     :  Optional[int]   =				q
								A     :  str   =				p - q * (a // b)

				assert a % d == 0 and b % d == 0
				assert d == a * x + b * y

				return (d, x, y)





def 							_lowerCamelCase			(					lowerCamelCase_:  int				,	lowerCamelCase_:  int		):



				'''simple docstring'''







				if b == 0:
								return (1, 0)
				((A) ,       (A))     :  str   =				extended_euclid(lowerCamelCase_				,	a % b		)
				A     :  str   =				a // b
				return (y, x - k * y)





def 							_lowerCamelCase			(					lowerCamelCase_:  int				,	lowerCamelCase_:  int		):



				'''simple docstring'''







				if a < b:
								A ,       A     :  Optional[Any]   =				b, a

				while a % b != 0:
								A ,       A     :  Dict   =				b, a % b

				return b


if __name__ == "__main__":
					from doctest import testmod

					testmod(name="modular_division", verbose=True)
					testmod(name="modular_division2", verbose=True)
					testmod(name="invert_modulo", verbose=True)
					testmod(name="extended_gcd", verbose=True)
					testmod(name="extended_euclid", verbose=True)
					testmod(name="greatest_common_divisor", verbose=True)

def 							_lowerCamelCase			(					lowerCamelCase_:  int		):



				'''simple docstring'''







				if not isinstance(lowerCamelCase_				,	lowerCamelCase_		):
								raise ValueError('''double_factorial() only accepts integral values'''		)
				if num < 0:
								raise ValueError('''double_factorial() not defined for negative values'''		)
				A     :  int   =				1
				for i in range(lowerCamelCase_				,	0				,	-2		):
								value *= i
				return value


if __name__ == "__main__":
					import doctest

					doctest.testmod()