



"""simple docstring"""


from math import factorial







class       A_			:



						"""simple docstring"""






						def __init__(					self :List[str]   ,  lowercase_ :List[str]   ,  lowercase_ :Optional[int]					)				->			Union[str, Any]:
												UpperCAmelCase             = real
												if isinstance(lowercase_   ,  lowercase_					):
																		UpperCAmelCase             = [1] * rank
												else:
																		UpperCAmelCase             = rank






						def __repr__(					self :List[str]					)				->			Optional[Any]:
												return (
												    f"""{self.real}+"""
												    f"""{'+'.join(str(lowercase_					)+'E'+str(n+1					)for n,dual in enumerate(self.duals					)					)}"""
												)






						def 	UpperCAmelCase__     (					self :Tuple					)				->			Union[str, Any]:
												UpperCAmelCase             = self.duals.copy()
												while cur[-1] == 0:
																		cur.pop(-1					)
												return Dual(self.real   ,  lowercase_					)






						def __add__(					self :Tuple   ,  lowercase_ :str					)				->			Any:
												if not isinstance(lowercase_   ,  lowercase_					):
																		return Dual(self.real + other   ,  self.duals					)
												UpperCAmelCase             = self.duals.copy()
												UpperCAmelCase             = other.duals.copy()
												if len(lowercase_					) > len(lowercase_					):
																		o_dual.extend([1] * (len(lowercase_					) - len(lowercase_					))					)
												elif len(lowercase_					) < len(lowercase_					):
																		s_dual.extend([1] * (len(lowercase_					) - len(lowercase_					))					)
												UpperCAmelCase             = []
												for i in range(len(lowercase_					)					):
																		new_duals.append(s_dual[i] + o_dual[i]					)
												return Dual(self.real + other.real   ,  lowercase_					)

						__UpperCamelCase						=							__add__






						def __sub__(					self :List[Any]   ,  lowercase_ :int					)				->			str:
												return self + other * -1






						def __mul__(					self :int   ,  lowercase_ :List[str]					)				->			Tuple:
												if not isinstance(lowercase_   ,  lowercase_					):
																		UpperCAmelCase             = []
																		for i in self.duals:
																								new_duals.append(i * other					)
																		return Dual(self.real * other   ,  lowercase_					)
												UpperCAmelCase             = [0] * (len(self.duals					) + len(other.duals					) + 1)
												for i, item in enumerate(self.duals					):
																		for j, jtem in enumerate(other.duals					):
																								new_duals[i + j + 1] += item * jtem
												for k in range(len(self.duals					)					):
																		new_duals[k] += self.duals[k] * other.real
												for index in range(len(other.duals					)					):
																		new_duals[index] += other.duals[index] * self.real
												return Dual(self.real * other.real   ,  lowercase_					)

						__UpperCamelCase						=							__mul__






						def __truediv__(					self :Tuple   ,  lowercase_ :List[Any]					)				->			Tuple:
												if not isinstance(lowercase_   ,  lowercase_					):
																		UpperCAmelCase             = []
																		for i in self.duals:
																								new_duals.append(i / other					)
																		return Dual(self.real / other   ,  lowercase_					)
												raise ValueError






						def __floordiv__(					self :Tuple   ,  lowercase_ :Optional[Any]					)				->			Dict:
												if not isinstance(lowercase_   ,  lowercase_					):
																		UpperCAmelCase             = []
																		for i in self.duals:
																								new_duals.append(i // other					)
																		return Dual(self.real // other   ,  lowercase_					)
												raise ValueError






						def __pow__(					self :Tuple   ,  lowercase_ :List[Any]					)				->			Any:
												if n < 0 or isinstance(lowercase_   ,  lowercase_					):
																		raise ValueError('power must be a positive integer'					)
												if n == 0:
																		return 1
												if n == 1:
																		return self
												UpperCAmelCase             = self
												for _ in range(n - 1					):
																		x *= self
												return x


def  _lowerCAmelCase      (   lowercase_		,	lowercase_		,	lowercase_						):
						if not callable(lowercase_						):
												raise ValueError('differentiate() requires a function as input for func'						)
						if not isinstance(lowercase_		,	(float, int)						):
												raise ValueError('differentiate() requires a float as input for position'						)
						if not isinstance(lowercase_		,	lowercase_						):
												raise ValueError('differentiate() requires an int as input for order'						)
						UpperCAmelCase             = Dual(lowercase_		,	1						)
						UpperCAmelCase             = func(lowercase_						)
						if order == 0:
												return result.real
						return result.duals[order - 1] * factorial(lowercase_						)


if __name__ == "__main__":
				import doctest

				doctest.testmod()

				def  _lowerCAmelCase      (   lowercase_						):
										return y**2 * y**4






				print(differentiate(f, 9, 2))






'''simple docstring'''




import math
import unittest




def 							lowerCamelCase	(      UpperCAmelCase__       :					int )			->      bool:
							assert isinstance(UpperCAmelCase__      ,      UpperCAmelCase__ ) and (
							    number >= 0
							), "'number' must been an int and positive"

							if 1 < number < 4:
														# 2 and 3 are primes
														return True
							elif number < 2 or number % 2 == 0 or number % 3 == 0:
														# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
														return False

							# All primes number are in format of 6k +/- 1
							for i in range(5      ,      int(math.sqrt(UpperCAmelCase__ ) + 1 )      ,      6 ):
														if number % i == 0 or number % (i + 2) == 0:
																					return False
							return True





class     __magic_name__						(    unittest.TestCase):







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Dict    ):
										self.assertTrue(is_prime(2    )    )
										self.assertTrue(is_prime(3    )    )
										self.assertTrue(is_prime(5    )    )
										self.assertTrue(is_prime(7    )    )
										self.assertTrue(is_prime(11    )    )
										self.assertTrue(is_prime(13    )    )
										self.assertTrue(is_prime(17    )    )
										self.assertTrue(is_prime(19    )    )
										self.assertTrue(is_prime(23    )    )
										self.assertTrue(is_prime(29    )    )







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Optional[Any]    ):
										with self.assertRaises(lowercase_    ):
																	is_prime(-19    )
										self.assertFalse(
										    is_prime(0    )				,			"""Zero doesn't have any positive factors, primes must have exactly two."""				,			)
										self.assertFalse(
										    is_prime(1    )				,			"""One only has 1 positive factor, primes must have exactly two."""				,			)
										self.assertFalse(is_prime(2 * 2    )    )
										self.assertFalse(is_prime(2 * 3    )    )
										self.assertFalse(is_prime(3 * 3    )    )
										self.assertFalse(is_prime(3 * 5    )    )
										self.assertFalse(is_prime(3 * 5 * 7    )    )


if __name__ == "__main__":
						unittest.main()





