def divi(x,y):
    return x/y
def per(x,y):
    return (x/y)*100
def squ(x):
    return x*x
def pow(x,y):
    return x**y
def lcm(x,y):

    L=x if x>y else y

    while L<=x*y:

        if L%x==0 and L%y==0:

            return L

        L+=1
def compute_hcf(x, y) -> int:


    if x > y:
        smaller = y
    else:
        smaller = x
    for i in range(1, smaller+1):
        if((x % i == 0) and (y % i == 0)):
            hcf = i 
    return hcf
def sine(x):
    import math
    return math.sin(x)

print('''OPERATION NUMBER/CODE/SYMBOL:
ADDITION- (1)- (add) - (+)
SUBTRACTION- (2)- (sub) - (-)
MULTIPLICATION- (3) - (multi) - (*)
DIVISION - (4) - (div) - (/)
PERCENTAGE - (5) - (per) - (%)
TO GET SQUARE OF A NUMBER - (6) - (sq) - (^2)
TO GET POWER OF A NUMBER - (7) - (pw) - (^)
TO GET FACTORIAL OF A NUMBER - (8) - (fact) - (!)
TO GET ROOT OF A NUMBER - (9) - (root) - (^.)
TO GET SQUARE ROOT OF A NUMBER - (10) - (sqr) - (^0.5)
TO GET LCM OF TWO NUMBERS - (11) - (lcm)
TO GET HCF OF TWO NUMBERS - (12) - (hcf)''')
while True:
   choice = input('''ENTER YOUR OPERATION NUMBER OR OPERATION CODE OR OPERATION SYMBOL:''')
   if choice == '1' or choice=='add' or choice=='+':
       sum=0
       while True:
           val=float(input('ENTER THE NUMBER OR ENTER 0 TO END:'))
           if val==0:
               break
           sum+=val
       print('YOUR FINAL ANSWER IS:')
       print(sum)
   elif choice == '2' or choice=='sub' or choice=='-':
      sub=float(input('ENTER THE NUMBER OR ENTER 0 TO END:'))
      while True:
          val=float(input('ENTER THE NUMBER OR ENTER 0 TO END:'))
          if val==0:
              break
          sub-=val
      print('YOUR FINAL ANSWER IS')
      print(sub)
   elif choice == '3' or choice=='multi' or choice=='*':
       multi=1
       while True:
           val=float(input('ENTER THE NUMBER OR ENTER 1 TO END:'))
           if val==1:
               break
           multi*=val
       print('YOUR FINAL ANSWER IS')
       print(multi)
   elif choice == '4' or choice =='div' or choice =='/':
      a = float(input("ENTER YOUR FIRST NUMBER:"))
      b = float(input("ENTER YOUR SECOND NUMBER:"))
      print(a ,'/', b ,'=', divi(a,b))
   elif choice == '5' or choice =='per' or choice =='%':
      a = float(input("ENTER YOUR FIRST NUMBER:"))
      b = float(input("ENTER YOUR SECOND NUMBER:"))
      print(a ,'*', b,'/',100,'=', per(a,b))
   elif choice == '6' or choice == 'sq' or choice =='^2':
      a = float(input("ENTER YOUR NUMBER:"))
      print('SQUARE OF' ,a,'IS', squ(a))
   elif choice == '7' or choice =='pw' or choice =='^':
      a = float(input('ENTER YOUR BASE:'))
      b = float(input('ENTER YOUR POWER:'))
      print(a ,'^', b ,'=', pow(a,b))
   elif choice == '8' or choice =='fact' or choice =='!':
       num = int(input("ENTER YOUR NUMBER:"))    
       factorial = 1    
       if num < 0:    
          print(" FACTORIAL DOES NOT EXIST FOR NEGATIVE NUMBERS")    
       elif num == 0:    
            print("THE FACTORIAL OF 0 IS 1")    
       else:    
            for i in range(1,num + 1):    
                factorial = factorial*i    
            print("THE FACTORIAL OF ",num,"IS",factorial)
   elif choice == '9' or choice =='root' or choice =='^.':
        a=float(input('ENTER THE NUMBER:'))
        b=float(input('ENTER THE ROOT:'))
        if b%2==0:
            if a>=0:
                print(a**(1/b))
            else:
                print('NEGATIVE OF EVEN ROOT IS NOT POSSIBLE')
        else:
            print(a**(1/b))
   
   elif choice == '10' or choice == 'sqr' or choice =='^0.5':
       a=float(input('ENTER YOUR NUMBER:'))
       if a<0:
           print('SQUARE ROOT OF A NEGATIVE NUMBER IS NOT POSSIBLE')
       else:
           print('SQUARE ROOT OF',a,'IS',a**0.5)
    
   elif choice =='lcm' or choice== '11':
       a=float(input('ENTER YOUR FIRST NUMBER:'))
       b=float(input('ENTER YOUR SECOND NUMBER:'))
       print('LCM OF',a,'AND',b,'IS',lcm(a,b))
   elif choice == '12' or choice == 'hcf':
       a=int(input('ENTER YOUR FIRST NUMBER:'))
       b=int(input('ENTER YOUR SECOND NUMBER:'))
       print('HCM OF',a,'AND',b,'IS',compute_hcf(a,b)) 
   elif choice == '13' or choice=='sin' or choice== 's':
        a=float(input('ENTER THE ANGLE:'))
        print('SIN OF ANGLE',a,'=',sine(a))
       
   else:
       print('INVALID CHOICE')
       
   nxt_cal = input('DO YOU WANT TO DO AN ANOTHER CALCULATION(yes/no):')
   if nxt_cal == 'no':
       break
   elif nxt_cal == 'yes':
       continue
   else:
       print('INVALID CHOICE')
       break
