

"""simple docstring"""


from math import factorial

a					:dict[str, int]    = {str(digit): factorial(digit) for digit in range(10)}




def  _lowercase					(    __lowerCAmelCase							)       ->				int:
      if not isinstance(__lowerCAmelCase  ,					__lowerCAmelCase							):
            raise TypeError("""Parameter number must be int"""							)

      if number < 0:
            raise ValueError("""Parameter number must be greater than or equal to 0"""							)

      # Converts number in string to iterate on its digits and adds its factorial.
      return sum(DIGIT_FACTORIAL[digit] for digit in str(__lowerCAmelCase							)							)




def  _lowercase					(    __lowerCAmelCase = 60  ,					__lowerCAmelCase = 100_0000							)       ->				int:

      if not isinstance(__lowerCAmelCase  ,					__lowerCAmelCase							) or not isinstance(__lowerCAmelCase  ,					__lowerCAmelCase							):
            raise TypeError("""Parameters chain_length and number_limit must be int"""							)

      if chain_length <= 0 or number_limit <= 0:
            raise ValueError(
                """Parameters chain_length and number_limit must be greater than 0"""							)

      # the counter for the chains with the exact desired length
      SCREAMING_SNAKE_CASE__   :      str      		=	0
      # the cached sizes of the previous chains
      SCREAMING_SNAKE_CASE__   :      dict[int, int]      		=	{}

      for start_chain_element in range(1  ,					__lowerCAmelCase							):
            # The temporary set will contain the elements of the chain
            SCREAMING_SNAKE_CASE__   :      Optional[Any]      		=	set()
            SCREAMING_SNAKE_CASE__   :      List[str]      		=	0

            # Stop computing the chain when you find a cached size, a repeating item or the
            # length is greater then the desired one.
            SCREAMING_SNAKE_CASE__   :      str      		=	start_chain_element
            while (
                chain_element not in chain_sets_lengths
                and chain_element not in chain_set
                and chain_set_length <= chain_length
            ):
                  chain_set.add(__lowerCAmelCase							)
                  chain_set_length += 1
                  SCREAMING_SNAKE_CASE__   :      Union[str, Any]      		=	digit_factorial_sum(__lowerCAmelCase							)

            if chain_element in chain_sets_lengths:
                  chain_set_length += chain_sets_lengths[chain_element]

            SCREAMING_SNAKE_CASE__   :      str      		=	chain_set_length

            # If chain contains the exact amount of elements increase the counter
            if chain_set_length == chain_length:
                  chains_counter += 1

      return chains_counter


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    print(f'{solution()}')







"""simple docstring"""


from math import sqrt




def  _lowercase					(    __lowerCAmelCase							)       ->				bool:

      if 1 < number < 4:
            # 2 and 3 are primes
            return True
      elif number < 2 or number % 2 == 0 or number % 3 == 0:
            # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
            return False

      # All primes number are in format of 6k +/- 1
      for i in range(5  ,					int(sqrt(__lowerCAmelCase							) + 1							)  ,					6							):
            if number % i == 0 or number % (i + 2) == 0:
                  return False
      return True




def  _lowercase					(    __lowerCAmelCase = 1_0001							)       ->				int:
      SCREAMING_SNAKE_CASE__   :      Dict      		=	0
      SCREAMING_SNAKE_CASE__   :      Tuple      		=	1
      while count != nth and number < 3:
            number += 1
            if is_prime(__lowerCAmelCase							):
                  count += 1
      while count != nth:
            number += 2
            if is_prime(__lowerCAmelCase							):
                  count += 1
      return number


if __name__ == "__main__":
  print(f'{solution() = }')




