#!/usr/bin/python3

#####################################################################################
#                                                                                   #
#    Prob: Implement a python code to check whether a given number                  #
#          is ARMSTRONG number or prime or both.                                    #
#                                                                                   #
#####################################################################################

# Initialize flag for prime and armstrong no variable
flagp = 0
flaga = 0
# initialize sum
sum = 0

# Take input from the user
num = int(input("Enter a number: "))

# Prime number check begins

# prime numbers are greater than 1
if num > 1:
   # check for factors
   for i in range(2,num):
       if (num % i) == 0:
           """print(num,"is not a prime number")
# Operator // is Floor division - division that results into whole
# number adjusted to the left in the number line
           print("It is divided by",num//i)"""
           break
   else:
       flagp = 1
       #print(num,"is a prime number")
       
# if input number is less than
# or equal to 1, it is not prime
else:
   print("please enter valid positive number other than 1")

# Armstrong number check begins

# Changed num variable to string, 
# and calculated the length (number of digits)
order = len(str(num))

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** order
   temp //= 10

# Check armstrong num
if num == sum:
	flaga = 1
#   print(num,"is an Armstrong number")

# Result
if flaga == 0 and flagp == 0:
	print("Number is not Armstrong or prime number")
elif flaga == 1 and flagp == 1:
	print("Number is Armstrong number and prime number")
elif flaga == 1 and flagp == 0:
	print("Number is only Armstrong number")
elif flaga == 0 and flagp == 1:
	print("Number is only Prime number")	
