

"""simple docstring"""







def   __UpperCAmelCase    (   UpperCAmelCase_   :    int  )							->      int:

	'''simple docstring'''





	if not isinstance(UpperCAmelCase_      ,							UpperCAmelCase_  ):
		raise ValueError('multiplicative_persistence() only accepts integral values'  )
	if num < 0:
		raise ValueError('multiplicative_persistence() does not accept negative values'  )

	__snake_case      :							Any						=			0
	__snake_case      :							str						=			str(UpperCAmelCase_  )

	while len(UpperCAmelCase_  ) != 1:
		__snake_case      :							Union[str, Any]						=			[int(UpperCAmelCase_  ) for i in num_string]

		__snake_case      :							str						=			1
		for i in range(0      ,							len(UpperCAmelCase_  )  ):
			total *= numbers[i]

		__snake_case      :							Optional[Any]						=			str(UpperCAmelCase_  )

		steps += 1
	return steps
def   __UpperCAmelCase    (   UpperCAmelCase_   :    int  )							->      int:

	'''simple docstring'''





	if not isinstance(UpperCAmelCase_      ,							UpperCAmelCase_  ):
		raise ValueError('additive_persistence() only accepts integral values'  )
	if num < 0:
		raise ValueError('additive_persistence() does not accept negative values'  )

	__snake_case      :							Dict						=			0
	__snake_case      :							Optional[int]						=			str(UpperCAmelCase_  )

	while len(UpperCAmelCase_  ) != 1:
		__snake_case      :							List[Any]						=			[int(UpperCAmelCase_  ) for i in num_string]

		__snake_case      :							Union[str, Any]						=			0
		for i in range(0      ,							len(UpperCAmelCase_  )  ):
			total += numbers[i]

		__snake_case      :							Optional[int]						=			str(UpperCAmelCase_  )

		steps += 1
	return steps


if __name__ == "__main__":
	import doctest

	doctest.testmod()






"""simple docstring"""







def   __UpperCAmelCase    (   UpperCAmelCase_   :    int      ,							UpperCAmelCase_   :    int  )							->      int:

	'''simple docstring'''





	while a != 0:
		__snake_case		,    __snake_case      :							Union[str, Any]						=			b % a, a
	return b

def   __UpperCAmelCase    (   UpperCAmelCase_   :    int      ,							UpperCAmelCase_   :    int  )							->      int:

	'''simple docstring'''





	if gcd(UpperCAmelCase_      ,							UpperCAmelCase_  ) != 1:
		__snake_case      :							Union[str, Any]						=			F"mod inverse of {a!r} and {m!r} does not exist"
		raise ValueError(UpperCAmelCase_  )
	__snake_case		,    __snake_case		,    __snake_case      :							List[str]						=			1, 0, a
	__snake_case		,    __snake_case		,    __snake_case      :							Dict						=			0, 1, m
	while va != 0:
		__snake_case      :							List[str]						=			ua // va
		__snake_case		,    __snake_case		,    __snake_case		,    __snake_case		,    __snake_case		,    __snake_case      :							List[str]						=			(ua - q * va), (ua - q * va), (ua - q * va), va, va, va
	return ua % m





