


from math import pi, sqrt






def  __lowerCAmelCase					(SCREAMING_SNAKE_CASE      )->						float:




      """simple docstring"""

      if num <= 0:
            raise ValueError('''math domain error'''      )
      if num > 1_7_1.5:
            raise OverflowError('''math range error'''      )
      elif num - int(SCREAMING_SNAKE_CASE      ) not in (0, 0.5):
            raise NotImplementedError('''num must be an integer or a half-integer'''      )
      elif num == 0.5:
            return sqrt(SCREAMING_SNAKE_CASE      )
      else:
            return 1.0 if num == 1 else (num - 1) * gamma(num - 1      )






def  __lowerCAmelCase					()->						None:




      """simple docstring"""

      assert gamma(0.5      ) == sqrt(SCREAMING_SNAKE_CASE      )
      assert gamma(1      ) == 1.0
      assert gamma(2      ) == 1.0


if __name__ == "__main__":
   from doctest import testmod

   testmod()
   UpperCAmelCase    =					1.0
   while num:
      UpperCAmelCase    =					float(input("""Gamma of: """))
      print(f'''gamma({num}) = {gamma(num)}''')
      print("""\nEnter 0 to exit...""")



def  __lowerCAmelCase					(SCREAMING_SNAKE_CASE = 3      ,      SCREAMING_SNAKE_CASE = 7      ,      SCREAMING_SNAKE_CASE = 100_0000      )->						int:




      """simple docstring"""

      snake_case_ =   0
      snake_case_ =   1

      for current_denominator in range(1      ,      limit + 1      ):
            snake_case_ =   current_denominator * numerator // denominator
            if current_denominator % denominator == 0:
                  current_numerator -= 1
            if current_numerator * max_denominator > current_denominator * max_numerator:
                  snake_case_ =   current_numerator
                  snake_case_ =   current_denominator
      return max_numerator


if __name__ == "__main__":
   print(solution(numerator=3, denominator=7, limit=100_0000))