'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int = 998_001   ):


       """simple docstring"""







       for number in range(n - 1      ,     9_999      ,     -1   ):
              _UpperCAmelCase					:  Any											=   str(_UpperCAmelCase   )

              # checks whether 'str_number' is a palindrome.
              if str_number == str_number[::-1]:
                     _UpperCAmelCase					:  Tuple											=   999

                     # if 'number' is a product of two 3-digit numbers
                     # then number is the answer otherwise fetch next number.
                     while divisor != 99:
                            if (number % divisor == 0) and (len(str(number // divisor   )   ) == 3.0):
                                   return number
                            divisor -= 1
       raise ValueError("That number is larger than our acceptable range."   )


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


'''simple docstring'''




from __future__ import annotations

from collections.abc import Generator

def      UpperCamelCase_							( _UpperCAmelCase  :				int   )   ->   Generator[int, None, None]:


       """simple docstring"""







       if not isinstance(_UpperCAmelCase      ,     _UpperCAmelCase   ) or n < 1:
              raise Exception("Sequence only defined for positive integers"   )

       yield n
       while n != 1:
              if n % 2 == 0:
                     n //= 2
              else:
                     _UpperCAmelCase					:  Optional[Any]											=   3 * n + 1
              yield n

def      UpperCamelCase_							( )   ->   Any:


       """simple docstring"""







       _UpperCAmelCase					:  str											=   43
       _UpperCAmelCase					:  Optional[int]											=   tuple(collatz_sequence(_UpperCAmelCase   )   )
       print(_UpperCAmelCase   )
       print(F"""Collatz sequence from {n} took {len(_UpperCAmelCase   )} steps."""   )


if __name__ == "__main__":
  main()

