



'''simple docstring'''







import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union

import pandas as pd
import pyarrow as pa

import datasets
import datasets.config
from datasets.features.features import require_storage_cast
from datasets.table import table_cast


if TYPE_CHECKING:
							import sqlitea

							import sqlalchemy


SCREAMING_SNAKE_CASE__     : Optional[int]				=   datasets.utils.logging.get_logger(__name__)




@dataclass
class 				__lowerCAmelCase(							datasets.BuilderConfig      ):
			__snake_case  :		List[str]		=      None
			__snake_case  :		str		=      None
			__snake_case  :		List[Any]		=      None
			__snake_case  :		List[str]		=      True
			__snake_case  :		int		=      None
			__snake_case  :		Optional[int]		=      None
			__snake_case  :		Tuple		=      None
			__snake_case  :		Union[str, Any]		=      1_0_0_0_0
			__snake_case  :		Optional[Any]		=      None






			def 				_lowercase	(   self  :							List[str]	):




					"""simple docstring"""







					if self.sql is None:
							raise ValueError('sql must be specified'	)
					if self.con is None:
							raise ValueError('con must be specified'	)






			def 				_lowercase	(   self  :							Optional[Any]      ,       SCREAMING_SNAKE_CASE  :							str      ,       SCREAMING_SNAKE_CASE  :							Any = None      ,       ):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      config_kwargs.copy()
					# We need to stringify the Selectable object to make its hash deterministic

					# The process of stringifying is explained here: http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html
					SCREAMING_SNAKE_CASE_						:Any										=      config_kwargs["sql"]
					if not isinstance(lowercase_      ,       lowercase_	):
							if datasets.config.SQLALCHEMY_AVAILABLE and "sqlalchemy" in sys.modules:
									import sqlalchemy

									if isinstance(lowercase_      ,       sqlalchemy.sql.Selectable	):
											SCREAMING_SNAKE_CASE_						:str										=      sqlalchemy.create_engine(config_kwargs['con'].split('://'	)[0] + '://'	)
											SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      str(sql.compile(dialect=engine.dialect	)	)
											SCREAMING_SNAKE_CASE_						:int										=      sql_str
									else:
											raise TypeError(
											    f'Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(lowercase_	)}: {sql}'	)
							else:
									raise TypeError(
									    f'Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(lowercase_	)}: {sql}'	)
					SCREAMING_SNAKE_CASE_						:Optional[Any]										=      config_kwargs["con"]
					if not isinstance(lowercase_      ,       lowercase_	):
							SCREAMING_SNAKE_CASE_						:Tuple										=      id(lowercase_	)
							logger.info(
							    f'SQL connection \'con\' of type {type(lowercase_	)} couldn\'t be hashed properly. To enable hashing, specify \'con\' as URI string instead.'	)

					return super().create_config_id(lowercase_      ,       custom_features=lowercase_	)






			@property
			def 				_lowercase	(   self  :							int	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Optional[Any]										=      {
					    "index_col": self.index_col,
					    "columns": self.columns,
					    "params": self.params,
					    "coerce_float": self.coerce_float,
					    "parse_dates": self.parse_dates,
					}
					return pd_read_sql_kwargs




class 				__lowerCAmelCase(							datasets.ArrowBasedBuilder      ):
			__snake_case  :		Dict		=      SqlConfig






			def 				_lowercase	(   self  :							List[Any]	):




					"""simple docstring"""







					return datasets.DatasetInfo(features=self.config.features	)






			def 				_lowercase	(   self  :							List[str]      ,       SCREAMING_SNAKE_CASE  :							Optional[Any]	):




					"""simple docstring"""







					return [datasets.SplitGenerator(name=datasets.Split.TRAIN      ,       gen_kwargs={}	)]






			def 				_lowercase	(   self  :							List[Any]      ,       SCREAMING_SNAKE_CASE  :							int	):




					"""simple docstring"""







					if self.config.features is not None:
							SCREAMING_SNAKE_CASE_						:int										=      self.config.features.arrow_schema
							if all(not require_storage_cast(lowercase_	) for feature in self.config.features.values()	):
									# cheaper cast
									SCREAMING_SNAKE_CASE_						:str										=      pa.Table.from_arrays([pa_table[field.name] for field in schema]      ,       schema=lowercase_	)
							else:
									# more expensive cast; allows str <-> int/float or str to Audio for example
									SCREAMING_SNAKE_CASE_						:Tuple										=      table_cast(lowercase_      ,       lowercase_	)
					return pa_table






			def 				_lowercase	(   self  :							Union[str, Any]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Tuple										=      self.config.chunksize
					SCREAMING_SNAKE_CASE_						:Optional[Any]										=      pd.read_sql(
					    self.config.sql      ,       self.config.con      ,       chunksize=lowercase_      ,       **self.config.pd_read_sql_kwargs	)
					SCREAMING_SNAKE_CASE_						:Tuple										=      [sql_reader] if chunksize is None else sql_reader
					for chunk_idx, df in enumerate(lowercase_	):
							SCREAMING_SNAKE_CASE_						:Optional[Any]										=      pa.Table.from_pandas(lowercase_	)
							yield chunk_idx, self._cast_table(lowercase_	)


'''simple docstring'''
def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE							):
    """simple docstring"""






    if number != int(__SCREAMING_SNAKE_CASE							):
        raise ValueError("factorial() only accepts integral values"							)
    if number < 0:
        raise ValueError("factorial() not defined for negative values"							)
    snake_case_			:     int        =    1
    for i in range(1,		number + 1							):
        value *= i
    return value

def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE							):
    """simple docstring"""






    if not isinstance(__SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE							):
        raise ValueError("factorial() only accepts integral values"							)
    if n < 0:
        raise ValueError("factorial() not defined for negative values"							)
    return 1 if n == 0 or n == 1 else n * factorial(n - 1							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  a_           =    int(input("Enter a positive integer: ").strip() or 0)
  print(f"""factorial{n} is {factorial(n)}""")




