




lowercase__    :					Optional[Any]					=						{
    "0": 1,
    "1": 1,
    "2": 2,
    "3": 6,
    "4": 24,
    "5": 120,
    "6": 720,
    "7": 5040,
    "8": 4_0320,
    "9": 36_2880,
}

lowercase__    :					Union[str, Any]					=						{145: 145}

lowercase__    :					Dict					=						{
    145: 0,
    169: 3,
    3_6301: 3,
    1454: 3,
    871: 2,
    4_5361: 2,
    872: 2,
}


def 						lowerCamelCase__   (		_A							):







	'''simple docstring'''





	if n in CACHE_SUM_DIGIT_FACTORIALS:
		return CACHE_SUM_DIGIT_FACTORIALS[n]
	snake_case_		   =					sum(DIGIT_FACTORIALS[let] for let in str(_A							)							)
	snake_case_		   =					ret
	return ret


def 						lowerCamelCase__   (		_A					,     _A = None							):







	'''simple docstring'''





	snake_case_		   =					previous or set()
	if n in CHAIN_LENGTH_CACHE:
		return CHAIN_LENGTH_CACHE[n]
	snake_case_		   =					sum_digit_factorials(_A							)
	if next_number in previous:
		snake_case_		   =					0
		return 0
	else:
		previous.add(_A							)
		snake_case_		   =					1 + chain_length(_A					,     _A							)
		snake_case_		   =					ret
		return ret


def 						lowerCamelCase__   (		_A = 60					,     _A = 1000000							):







	'''simple docstring'''





	return sum(1 for i in range(1					,     _A							) if chain_length(_A							) == num_terms							)


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











from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available


lowercase__    :					List[str]					=						{
    "configuration_xlm_prophetnet": ["XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMProphetNetConfig"],
}

try:
		if not is_sentencepiece_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		lowercase__    :					Optional[Any]					=						["XLMProphetNetTokenizer"]

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		lowercase__    :					List[Any]					=						[
		    "XLM_PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST",
		    "XLMProphetNetDecoder",
		    "XLMProphetNetEncoder",
		    "XLMProphetNetForCausalLM",
		    "XLMProphetNetForConditionalGeneration",
		    "XLMProphetNetModel",
		    "XLMProphetNetPreTrainedModel",
		]


if TYPE_CHECKING:
		from .configuration_xlm_prophetnet import XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMProphetNetConfig

		try:
				if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_xlm_prophetnet import XLMProphetNetTokenizer

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_xlm_prophetnet import (
				    XLM_PROPHETNET_PRETRAINED_MODEL_ARCHIVE_LIST,
				    XLMProphetNetDecoder,
				    XLMProphetNetEncoder,
				    XLMProphetNetForCausalLM,
				    XLMProphetNetForConditionalGeneration,
				    XLMProphetNetModel,
				    XLMProphetNetPreTrainedModel,
				)

else:
		import sys

		lowercase__    :					Any					=						_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
