



"""simple docstring"""






_lowercase					:					Optional[int] 		=		{
    """0""": 1,
    """1""": 1,
    """2""": 2,
    """3""": 6,
    """4""": 2_4,
    """5""": 1_2_0,
    """6""": 7_2_0,
    """7""": 5_0_4_0,
    """8""": 4_0_3_2_0,
    """9""": 3_6_2_8_8_0,
}

_lowercase					:					Dict 		=		{1_4_5: 1_4_5}

_lowercase					:					Any 		=		{
    1_4_5: 0,
    1_6_9: 3,
    3_6_3_0_1: 3,
    1_4_5_4: 3,
    8_7_1: 2,
    4_5_3_6_1: 2,
    8_7_2: 2,
}






def 	snake_case__  (						__lowerCamelCase							:       Any      ):
			"""simple docstring"""
			if n in CACHE_SUM_DIGIT_FACTORIALS:
						return CACHE_SUM_DIGIT_FACTORIALS[n]
			lowerCamelCase__						:						Dict						      =sum(DIGIT_FACTORIALS[let] for let in str(_A      )      )
			lowerCamelCase__						:						List[Any]						      =ret
			return ret






def 	snake_case__  (						__lowerCamelCase							:       List[Any]				,						__lowerCamelCase							:       Any = None      ):
			"""simple docstring"""
			lowerCamelCase__						:						Tuple						      =previous or set()
			if n in CHAIN_LENGTH_CACHE:
						return CHAIN_LENGTH_CACHE[n]
			lowerCamelCase__						:						List[str]						      =sum_digit_factorials(_A      )
			if next_number in previous:
						lowerCamelCase__						:						Tuple						      =0
						return 0
			else:
						previous.add(_A      )
						lowerCamelCase__						:						str						      =1 + chain_length(_A				,						_A      )
						lowerCamelCase__						:						Dict						      =ret
						return ret






def 	snake_case__  (						__lowerCamelCase							:       int = 60				,						__lowerCamelCase							:       str = 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_torch_available


UpperCAmelCase__			:  Optional[Any]					     =     {
    """configuration_musicgen""": [
        """MUSICGEN_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """MusicgenConfig""",
        """MusicgenDecoderConfig""",
    ],
    """processing_musicgen""": ["""MusicgenProcessor"""],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__			:  Any					     =     [
      """MUSICGEN_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """MusicgenForConditionalGeneration""",
      """MusicgenForCausalLM""",
      """MusicgenModel""",
      """MusicgenPreTrainedModel""",
  ]

if TYPE_CHECKING:
  from .configuration_musicgen import (
      MUSICGEN_PRETRAINED_CONFIG_ARCHIVE_MAP,
      MusicgenConfig,
      MusicgenDecoderConfig,
  )
  from .processing_musicgen import MusicgenProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_musicgen import (
        MUSICGEN_PRETRAINED_MODEL_ARCHIVE_LIST,
        MusicgenForCausalLM,
        MusicgenForConditionalGeneration,
        MusicgenModel,
        MusicgenPreTrainedModel,
    )

else:
  import sys

  UpperCAmelCase__			:  Dict					     =     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




