


'''simple docstring'''





def 					a__    (				UpperCamelCase_	:			int,      UpperCamelCase_	:			int = 1_000	):
   if (not isinstance(UpperCamelCase_,      UpperCamelCase_	)) or (digit_position <= 0):
      raise ValueError('''Digit position must be a positive integer'''	)
   elif (not isinstance(UpperCamelCase_,      UpperCamelCase_	)) 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
   UpperCAmelCase__  :Any            =			(
       4 * _subsum(UpperCamelCase_,      1,      UpperCamelCase_	)
       - 2 * _subsum(UpperCamelCase_,      4,      UpperCamelCase_	)
       - _subsum(UpperCamelCase_,      5,      UpperCamelCase_	)
       - _subsum(UpperCamelCase_,      6,      UpperCamelCase_	)
   )

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


def 					a__    (				UpperCamelCase_	:			int,      UpperCamelCase_	:			int,      UpperCamelCase_	:			int	):
   UpperCAmelCase__  :int            =			0.0
   for sum_index in range(digit_pos_to_extract + precision	):
      UpperCAmelCase__  :Optional[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
         UpperCAmelCase__  :Any            =			pow(
             16,      digit_pos_to_extract - 1 - sum_index,      UpperCamelCase_	)
      else:
         UpperCAmelCase__  :Optional[Any]            =			pow(16,      digit_pos_to_extract - 1 - sum_index	)
      total += exponential_term / denominator
   return total


if __name__ == "__main__":
    import doctest

    doctest.testmod()







'''simple docstring'''





def 					a__    (				UpperCamelCase_	:			int	):
   UpperCAmelCase__  :str            =			[True for i in range(n + 1	)]
   UpperCAmelCase__  :List[str]            =			[i - 1 for i in range(n + 1	)]
   UpperCAmelCase__  :str            =			[]
   for i in range(2,      n + 1	):
      if is_prime[i]:
         primes.append(UpperCamelCase_	)
      for j in range(0,      len(UpperCamelCase_	)	):
         if i * primes[j] >= n:
            break
         UpperCAmelCase__  :List[str]            =			False

         if i % primes[j] == 0:
            UpperCAmelCase__  :Any            =			totients[i] * primes[j]
            break

         UpperCAmelCase__  :str            =			totients[i] * (primes[j] - 1)

   return totients


if __name__ == "__main__":
    import doctest

    doctest.testmod()



