






"""simple docstring"""





UpperCamelCase					=     {
    """0""": 1,
    """1""": 1,
    """2""": 2,
    """3""": 6,
    """4""": 24,
    """5""": 1_20,
    """6""": 7_20,
    """7""": 50_40,
    """8""": 4_03_20,
    """9""": 36_28_80,
}

UpperCamelCase					=     {1_45: 1_45}

UpperCamelCase					=     {
    1_45: 0,
    1_69: 3,
    3_63_01: 3,
    14_54: 3,
    8_71: 2,
    4_53_61: 2,
    8_72: 2,
}






def 							A(    snake_case_						):
       """simple docstring"""





       if n in CACHE_SUM_DIGIT_FACTORIALS:
              return CACHE_SUM_DIGIT_FACTORIALS[n]
       lowercase__:							Union[str, Any]         =     sum(DIGIT_FACTORIALS[let] for let in str(snake_case_						)						)
       lowercase__:							int         =     ret
       return ret






def 							A(    snake_case_		,  snake_case_ = None						):
       """simple docstring"""





       lowercase__:							Optional[Any]         =     previous or set()
       if n in CHAIN_LENGTH_CACHE:
              return CHAIN_LENGTH_CACHE[n]
       lowercase__:							Tuple         =     sum_digit_factorials(snake_case_						)
       if next_number in previous:
              lowercase__:							List[str]         =     0
              return 0
       else:
              previous.add(snake_case_						)
              lowercase__:							str         =     1 + chain_length(snake_case_		,  snake_case_						)
              lowercase__:							Union[str, Any]         =     ret
              return ret






def 							A(    snake_case_ = 60		,  snake_case_ = 1000000						):
       """simple docstring"""





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


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














"""simple docstring"""





import doctest

import projectq
from projectq.ops import H, Measure






def 							A(    snake_case_						):
       """simple docstring"""





       lowercase__:							Dict         =     quantum_engine.allocate_qubit()
       H | qubit
       Measure | qubit
       return int(snake_case_						)


if __name__ == "__main__":
  doctest.testmod()

  # initialises a new quantum backend
  UpperCamelCase					=     projectq.MainEngine()

  # Generate a list of 10 random numbers
  UpperCamelCase					=     [get_random_number(quantum_engine) for _ in range(10)]

  # Flushes the quantum engine from memory
  quantum_engine.flush()

  print("""Random numbers""", random_numbers_list)






