
'''simple docstring'''





def     snake_case							(						UpperCAmelCase		)->     str:







      """simple docstring"""
      __A    		=     1
      __A    		=     0
      __A    		=     1
      __A    		=     1
      __A    		=     3
      __A    		=     3
      __A    		=     limit
      __A    		=     0

      __A    		=     ''
      while counter != decimal + 1:
            if 4 * q + r - t < n * t:
                  result += str(UpperCAmelCase		)
                  if counter == 0:
                        result += "."

                  if decimal == counter:
                        break

                  counter += 1
                  __A    		=     1_0 * (r - n * t)
                  __A    		=     ((1_0 * (3 * q + r)) // t) - 1_0 * n
                  q *= 1_0
                  __A    		=     nr
            else:
                  __A    		=     (2 * q + r) * l
                  __A    		=     (q * (7 * k) + 2 + (r * l)) // (t * l)
                  q *= k
                  t *= l
                  l += 2
                  k += 1
                  __A    		=     nn
                  __A    		=     nr
      return result





def     snake_case							(						)->     None:







      """simple docstring"""
      print(f'{calculate_pi(5_0		) = }'		)
      import doctest

      doctest.testmod()


if __name__ == "__main__":
 main()








'''simple docstring'''





from __future__ import annotations





def     snake_case							(						UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase		)->     tuple[float, float]:







      """simple docstring"""
      assert (
          c % greatest_common_divisor(UpperCAmelCase ,					UpperCAmelCase		) == 0
      )  # greatest_common_divisor(a,b) function implemented below
      ((__A)		, (__A)		, (__A))    		=     extended_gcd(UpperCAmelCase ,					UpperCAmelCase		)  # extended_gcd(a,b) function implemented below
      __A    		=     c / d
      return (r * x, r * y)





def     snake_case							(						UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase = 2		)->     None:







      """simple docstring"""
      ((__A)		, (__A))    		=     diophantine(UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase		)  # Initial value
      __A    		=     greatest_common_divisor(UpperCAmelCase ,					UpperCAmelCase		)
      __A    		=     a // d
      __A    		=     b // d

      for i in range(UpperCAmelCase		):
            __A    		=     xa + i * q
            __A    		=     ya - i * p
            print(UpperCAmelCase ,					UpperCAmelCase		)





def     snake_case							(						UpperCAmelCase ,					UpperCAmelCase		)->     int:







      """simple docstring"""
      if a < b:
            __A		, __A    		=     b, a

      while a % b != 0:
            __A		, __A    		=     b, a % b

      return b





def     snake_case							(						UpperCAmelCase ,					UpperCAmelCase		)->     tuple[int, int, int]:







      """simple docstring"""
      assert a >= 0 and b >= 0

      if b == 0:
            __A		, __A		, __A    		=     a, 1, 0
      else:
            ((__A)		, (__A)		, (__A))    		=     extended_gcd(UpperCAmelCase ,					a % b		)
            __A    		=     q
            __A    		=     p - q * (a // b)

      assert a % d == 0 and b % d == 0
      assert d == a * x + b * y

      return (d, x, y)


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

 testmod(name="diophantine", verbose=True)
 testmod(name="diophantine_all_soln", verbose=True)
 testmod(name="extended_gcd", verbose=True)
 testmod(name="greatest_common_divisor", verbose=True)






