






'''simple docstring'''
import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

a_					=	3





def 	_a(					UpperCamelCase__			:  int							):




      '''simple docstring'''






      print('''Generating primitive root of p'''							)
      while True:
            SCREAMING_SNAKE_CASE__       :			Optional[int]													=random.randrange(3,		UpperCamelCase__							)
            if pow(UpperCamelCase__,		2,		UpperCamelCase__							) == 1:
                  continue
            if pow(UpperCamelCase__,		UpperCamelCase__,		UpperCamelCase__							) == 1:
                  continue
            return g





def 	_a(					UpperCamelCase__			:  int							):




      '''simple docstring'''






      print('''Generating prime p...'''							)
      SCREAMING_SNAKE_CASE__       :			Optional[int]													=rabin_miller.generate_large_prime(UpperCamelCase__							)  # select large prime number.
      SCREAMING_SNAKE_CASE__       :			Tuple													=primitive_root(UpperCamelCase__							)  # one primitive root on modulo p.
      SCREAMING_SNAKE_CASE__       :			Any													=random.randrange(3,		UpperCamelCase__							)  # private_key -> have to be greater than 2 for safety.
      SCREAMING_SNAKE_CASE__       :			int													=cryptomath.find_mod_inverse(pow(UpperCamelCase__,		UpperCamelCase__,		UpperCamelCase__							),		UpperCamelCase__							)

      SCREAMING_SNAKE_CASE__       :			int													=(key_size, e_a, e_a, p)
      SCREAMING_SNAKE_CASE__       :			Any													=(key_size, d)

      return public_key, private_key





def 	_a(					UpperCamelCase__			:  str,		UpperCamelCase__			:  int							):




      '''simple docstring'''






      if os.path.exists(f"{name}_pubkey.txt"							) or os.path.exists(f"{name}_privkey.txt"							):
            print('''\nWARNING:'''							)
            print(
                f"\"{name}_pubkey.txt\" or \"{name}_privkey.txt\" already exists. \n"
                '''Use a different name or delete these files and re-run this program.'''							)
            sys.exit()

      SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__       :			int													=generate_key(UpperCamelCase__							)
      print(f"\nWriting public key to file {name}_pubkey.txt..."							)
      with open(f"{name}_pubkey.txt",		'''w'''							) as fo:
            fo.write(f"{public_key[0]},{public_key[1]},{public_key[2]},{public_key[3]}"							)

      print(f"Writing private key to file {name}_privkey.txt..."							)
      with open(f"{name}_privkey.txt",		'''w'''							) as fo:
            fo.write(f"{private_key[0]},{private_key[1]}"							)





def 	_a(					):




      '''simple docstring'''






      print('''Making key files...'''							)
      make_key_files('''elgamal''',		2_0_4_8							)
      print('''Key files generation successful'''							)


if __name__ == "__main__":
  main()







'''simple docstring'''
from math import factorial





def 	_a(					UpperCamelCase__			:  int = 1_0_0							):




      '''simple docstring'''






      return sum(int(UpperCamelCase__							) for x in str(factorial(UpperCamelCase__							)							)							)


if __name__ == "__main__":
  print(solution(int(input('Enter the Number: ').strip())))