




"""simple docstring"""





def 						lowerCAmelCase							(	lowerCamelCase						):
						'''simple docstring'''


						snake_case__    :   List[str]							     =   1
						snake_case__    :   List[str]							     =   0
						snake_case__    :   List[Any]							     =   1
						snake_case__    :   str							     =   1
						snake_case__    :   List[Any]							     =   3
						snake_case__    :   Any							     =   3
						snake_case__    :   Any							     =   limit
						snake_case__    :   str							     =   0

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

																		if decimal == counter:
																								break

																		counter += 1
																		snake_case__    :   Tuple							     =   10 * (r - n * t)
																		snake_case__    :   Optional[int]							     =   ((10 * (3 * q + r)) // t) - 10 * n
																		q *= 10
																		snake_case__    :   List[str]							     =   nr
												else:
																		snake_case__    :   Tuple							     =   (2 * q + r) * l
																		snake_case__    :   Optional[int]							     =   (q * (7 * k) + 2 + (r * l)) // (t * l)
																		q *= k
																		t *= l
																		l += 2
																		k += 1
																		snake_case__    :   Any							     =   nn
																		snake_case__    :   List[Any]							     =   nr
						return result



def 						lowerCAmelCase							(	):
						'''simple docstring'''


						print(f'''{calculate_pi(50						) = }'''						)
						import doctest

						doctest.testmod()


if __name__ == "__main__":
							main()








"""simple docstring"""





from __future__ import annotations

import math
import random

def 						lowerCAmelCase							(	lowerCamelCase ,     lowerCamelCase ,     lowerCamelCase						):
						'''simple docstring'''


						snake_case__    :   Tuple							     =   d * e - 1
						snake_case__    :   Optional[int]							     =   0
						snake_case__    :   Tuple							     =   0
						while p == 0:
												snake_case__    :   Optional[int]							     =   random.randint(2 ,     n - 1						)
												snake_case__    :   Tuple							     =   k
												while True:
																		if t % 2 == 0:
																								snake_case__    :   List[Any]							     =   t // 2
																								snake_case__    :   Union[str, Any]							     =   (g**t) % n
																								snake_case__    :   Dict							     =   math.gcd(x - 1 ,     lowerCamelCase						)
																								if x > 1 and y > 1:
																														snake_case__    :   Union[str, Any]							     =   y
																														snake_case__    :   str							     =   n // y
																														break  # find the correct factors
																		else:
																								break  # t is not divisible by 2, break and choose another g
						return sorted([p, q]						)


if __name__ == "__main__":
							import doctest

							doctest.testmod()


