


'''simple docstring'''







from __future__ import annotations




def        __lowercase						(      __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE		)				->					bool:
     """simple docstring"""




     __a       =   get_failure_array(__SCREAMING_SNAKE_CASE		)

     # 2) Step through text searching for pattern
     __a ,						__a       =   0, 0  # index into text, pattern
     while i < len(__SCREAMING_SNAKE_CASE		):
          if pattern[j] == text[i]:
               if j == (len(__SCREAMING_SNAKE_CASE		) - 1):
                    return True
               j += 1

          # if this is a prefix in our pattern
          # just go back far enough to continue
          elif j > 0:
               __a       =   failure[j - 1]
               continue
          i += 1
     return False




def        __lowercase						(      __SCREAMING_SNAKE_CASE		)				->					list[int]:
     """simple docstring"""




     __a       =   [0]
     __a       =   0
     __a       =   1
     while j < len(__SCREAMING_SNAKE_CASE		):
          if pattern[i] == pattern[j]:
               i += 1
          elif i > 0:
               __a       =   failure[i - 1]
               continue
          j += 1
          failure.append(__SCREAMING_SNAKE_CASE		)
     return failure


if __name__ == "__main__":
 # Test 1)
 SCREAMING_SNAKE_CASE_      =			'abc1abc12'
 SCREAMING_SNAKE_CASE_      =			'alskfjaldsabc1abc1abc12k23adsfabcabc'
 SCREAMING_SNAKE_CASE_      =			'alskfjaldsk23adsfabcabc'
 assert kmp(pattern, texta) and not kmp(pattern, texta)

 # Test 2)
 SCREAMING_SNAKE_CASE_      =			'ABABX'
 SCREAMING_SNAKE_CASE_      =			'ABABZABABYABABX'
 assert kmp(pattern, text)

 # Test 3)
 SCREAMING_SNAKE_CASE_      =			'AAAB'
 SCREAMING_SNAKE_CASE_      =			'ABAAAAAB'
 assert kmp(pattern, text)

 # Test 4)
 SCREAMING_SNAKE_CASE_      =			'abcdabcy'
 SCREAMING_SNAKE_CASE_      =			'abcxabcdabxabcdabcdabcy'
 assert kmp(pattern, text)

 # Test 5)
 SCREAMING_SNAKE_CASE_      =			'aabaabaaa'
 assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]










'''simple docstring'''







from math import pi, sqrt




def        __lowercase						(      __SCREAMING_SNAKE_CASE		)				->					float:
     """simple docstring"""




     if num <= 0:
          raise ValueError("""math domain error"""		)
     if num > 171.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        __lowercase						(      )				->					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()
 SCREAMING_SNAKE_CASE_      =			1.0
 while num:
  SCREAMING_SNAKE_CASE_      =			float(input('Gamma of: '))
  print(f"""gamma({num}) = {gamma(num)}""")
  print('\nEnter 0 to exit...')






