



'''simple docstring'''

import math






def 		_snake_case		(					_SCREAMING_SNAKE_CASE     :						Any							)			->						list:







	"""simple docstring"""

	if n <= 0:
		raise ValueError("""Only positive integers have prime factors"""							)
	lowerCAmelCase    =	[]
	while n % 2 == 0:
		pf.append(2							)
		lowerCAmelCase    =	int(n / 2							)
	for i in range(3							,		int(math.sqrt(lowercase_							)							) + 1							,		2							):
		while n % i == 0:
			pf.append(lowercase_							)
			lowerCAmelCase    =	int(n / i							)
	if n > 2:
		pf.append(lowercase_							)
	return pf






def 		_snake_case		(					_SCREAMING_SNAKE_CASE     :						Optional[Any]							)			->						int:







	"""simple docstring"""

	if n <= 0:
		raise ValueError("""Only positive numbers are accepted"""							)
	lowerCAmelCase    =	1
	lowerCAmelCase    =	1
	while n % 2 == 0:
		temp += 1
		lowerCAmelCase    =	int(n / 2							)
	div *= temp
	for i in range(3							,		int(math.sqrt(lowercase_							)							) + 1							,		2							):
		lowerCAmelCase    =	1
		while n % i == 0:
			temp += 1
			lowerCAmelCase    =	int(n / i							)
		div *= temp
	if n > 1:
		div *= 2
	return div






def 		_snake_case		(					_SCREAMING_SNAKE_CASE     :						int							)			->						int:







	"""simple docstring"""

	if n <= 0:
		raise ValueError("""Only positive numbers are accepted"""							)
	lowerCAmelCase    =	1
	lowerCAmelCase    =	1
	while n % 2 == 0:
		temp += 1
		lowerCAmelCase    =	int(n / 2							)
	if temp > 1:
		s *= (2**temp - 1) / (2 - 1)
	for i in range(3							,		int(math.sqrt(lowercase_							)							) + 1							,		2							):
		lowerCAmelCase    =	1
		while n % i == 0:
			temp += 1
			lowerCAmelCase    =	int(n / i							)
		if temp > 1:
			s *= (i**temp - 1) / (i - 1)
	return int(lowercase_							)






def 		_snake_case		(					_SCREAMING_SNAKE_CASE     :						Optional[Any]							)			->						int:







	"""simple docstring"""
	lowerCAmelCase    =	n
	for x in set(prime_factors(lowercase_							)							):
		s *= (x - 1) / x
	return int(lowercase_							)


if __name__ == "__main__":
				import doctest

				doctest.testmod()






"""simple docstring"""


from __future__ import annotations




def     lowercase__			(    lowercase_						,lowercase_						,lowercase_	)    ->						int:




      """simple docstring"""

      assert n > 1 and a > 0 and greatest_common_divisor(lowercase_						,lowercase_	) == 1
      ((_UpperCamelCase),     (_UpperCamelCase),     (_UpperCamelCase))					:		int  =				extended_gcd(lowercase_						,lowercase_	)  # Implemented below
      _UpperCamelCase					:		Any  =				(b * s) % n
      return x




def     lowercase__			(    lowercase_						,lowercase_	)    ->						int:




      """simple docstring"""

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




def     lowercase__			(    lowercase_						,lowercase_						,lowercase_	)    ->						int:




      """simple docstring"""

      _UpperCamelCase					:		Union[str, Any]  =				invert_modulo(lowercase_						,lowercase_	)
      _UpperCamelCase					:		Any  =				(b * s) % n
      return x




def     lowercase__			(    lowercase_						,lowercase_	)    ->						tuple[int, int, int]:




      """simple docstring"""

      assert a >= 0 and b >= 0

      if b == 0:
            _UpperCamelCase,     _UpperCamelCase,     _UpperCamelCase					:		str  =				a, 1, 0
      else:
            ((_UpperCamelCase),     (_UpperCamelCase),     (_UpperCamelCase))					:		str  =				extended_gcd(lowercase_						,a % b	)
            _UpperCamelCase					:		Dict  =				q
            _UpperCamelCase					:		Tuple  =				p - q * (a // b)

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

      return (d, x, y)




def     lowercase__			(    lowercase_						,lowercase_	)    ->						tuple[int, int]:




      """simple docstring"""

      if b == 0:
            return (1, 0)
      ((_UpperCamelCase),     (_UpperCamelCase))					:		Optional[Any]  =				extended_euclid(lowercase_						,a % b	)
      _UpperCamelCase					:		Dict  =				a // b
      return (y, x - k * y)




def     lowercase__			(    lowercase_						,lowercase_	)    ->						int:




      """simple docstring"""

      if a < b:
            _UpperCamelCase,     _UpperCamelCase					:		List[Any]  =				b, a

      while a % b != 0:
            _UpperCamelCase,     _UpperCamelCase					:		List[Any]  =				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)
