

"""simple docstring"""


def 					a__					(					__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE = 1_0_0_0				)			->			str:
							if (not isinstance(__snake_case      ,				__snake_case				)) or (digit_position <= 0):
														raise ValueError("Digit position must be a positive integer"				)
							elif (not isinstance(__snake_case      ,				__snake_case				)) or (precision < 0):
														raise ValueError("Precision must be a nonnegative integer"				)

							# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
							# accurate
							__lowerCAmelCase: Any					   =    (
							    4 * _subsum(__snake_case      ,				1      ,				__snake_case				)
							    - 2 * _subsum(__snake_case      ,				4      ,				__snake_case				)
							    - _subsum(__snake_case      ,				5      ,				__snake_case				)
							    - _subsum(__snake_case      ,				6      ,				__snake_case				)
							)

							# return the first hex digit of the fractional part of the result
							return hex(int((sum_result % 1) * 1_6				)				)[2:]






def 					a__					(					__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)			->			float:
							__lowerCAmelCase: Any					   =    0.0
							for sum_index in range(digit_pos_to_extract + precision				):
														__lowerCAmelCase: List[Any]					   =    8 * sum_index + denominator_addend
														if sum_index < digit_pos_to_extract:
																					# if the exponential term is an integer and we mod it by the denominator
																					# before dividing, only the integer part of the sum will change;
																					# the fractional part will not
																					__lowerCAmelCase: Any					   =    pow(
																					    1_6      ,				digit_pos_to_extract - 1 - sum_index      ,				__snake_case				)
														else:
																					__lowerCAmelCase: str					   =    pow(1_6      ,				digit_pos_to_extract - 1 - sum_index				)
														total += exponential_term / denominator
							return total


if __name__ == "__main__":
			import doctest

			doctest.testmod()





"""simple docstring"""


import math






def 					a__					(					__SCREAMING_SNAKE_CASE				)			->			list:
		if n <= 0:
				raise ValueError("Only positive integers have prime factors"				)
		__lowerCAmelCase: Tuple					   =    []
		while n % 2 == 0:
				pf.append(2				)
				__lowerCAmelCase: str					   =    int(n / 2				)
		for i in range(3      ,				int(math.sqrt(__SCREAMING_SNAKE_CASE				)				) + 1      ,				2				):
				while n % i == 0:
						pf.append(__SCREAMING_SNAKE_CASE				)
						__lowerCAmelCase: List[Any]					   =    int(n / i				)
		if n > 2:
				pf.append(__SCREAMING_SNAKE_CASE				)
		return pf






def 					a__					(					__SCREAMING_SNAKE_CASE				)			->			int:
		if n <= 0:
				raise ValueError("Only positive numbers are accepted"				)
		__lowerCAmelCase: int					   =    1
		__lowerCAmelCase: str					   =    1
		while n % 2 == 0:
				temp += 1
				__lowerCAmelCase: Dict					   =    int(n / 2				)
		div *= temp
		for i in range(3      ,				int(math.sqrt(__SCREAMING_SNAKE_CASE				)				) + 1      ,				2				):
				__lowerCAmelCase: int					   =    1
				while n % i == 0:
						temp += 1
						__lowerCAmelCase: Tuple					   =    int(n / i				)
				div *= temp
		if n > 1:
				div *= 2
		return div






def 					a__					(					__SCREAMING_SNAKE_CASE				)			->			int:
		if n <= 0:
				raise ValueError("Only positive numbers are accepted"				)
		__lowerCAmelCase: Dict					   =    1
		__lowerCAmelCase: int					   =    1
		while n % 2 == 0:
				temp += 1
				__lowerCAmelCase: Tuple					   =    int(n / 2				)
		if temp > 1:
				s *= (2**temp - 1) / (2 - 1)
		for i in range(3      ,				int(math.sqrt(__SCREAMING_SNAKE_CASE				)				) + 1      ,				2				):
				__lowerCAmelCase: List[Any]					   =    1
				while n % i == 0:
						temp += 1
						__lowerCAmelCase: List[str]					   =    int(n / i				)
				if temp > 1:
						s *= (i**temp - 1) / (i - 1)
		return int(__SCREAMING_SNAKE_CASE				)






def 					a__					(					__SCREAMING_SNAKE_CASE				)			->			int:
		__lowerCAmelCase: Optional[int]					   =    n
		for x in set(prime_factors(__SCREAMING_SNAKE_CASE				)				):
				s *= (x - 1) / x
		return int(__SCREAMING_SNAKE_CASE				)


if __name__ == "__main__":
			import doctest

			doctest.testmod()


