Factors of Numbers in Python

#---------------------------- finding factors of a number  --------------------------------

num = int(input("Enter a number : "))
print("The factors are : ")
for i in range(1,num+1):
    if(num%i == 0):
        print(i,end =' ')
#---------------------------- finding a number is a perfect number  --------------------------


# A number is said to be perfect number if 'sum of its factor is equal' to the given number 

num = int(input("Enter a per number : "))
sum =0

for i in range(1,num):
    if(num%i == 0):

        sum+=i
if(sum == num):
    print(num,"is a perfect  number.")

#---------------------------- finding a number is a abundant number  ------------------------

# A number is said to be perfect number if 'sum of its factor is greater' than given number 

num = int(input("Enter a ab number : "))
sum =0

for i in range(1,num):
    if(num%i == 0):
        
        sum+=i
if(sum > num):
    print(num,"is a abundant  number.")
#---------------------------- finding a number is a deficient number  ------------------------

# A number is said to be deficient number if 'sum of its factor is lesser' than given number 

num = int(input("Enter a def number : "))
sum =0

for i in range(1,num):
    if(num%i == 0):
        
        sum+=i
if(sum < num):
    print(num,"is a Deficient number.")   
#---------------------------- finding a number is a amicable pair ----------------------------

# A pair number is said to be Amicable pair if 'sum of factor of num1' == num2 and 'sum of factor of num2' == num1    

    
num1 = int(input("Enter 1st number : "))
num2 = int(input("Enter 2nd number : "))
sum1 =0
sum2 =0

for i in range(1,num1):
    if(num1%i == 0):
        
        sum1+=i
for j in range(1,num2):
    if(num2%j == 0):
        
        sum2+=j
if(sum1 == num2 and sum2 == num1):
    print(num1,",",num2,"is a Amicable Pair") 
else:
    print(num1,",",num2,"is not a Amicable Pair") 

Join our team, where career growth knows no limits.

For More Details

Our internship program guarantees personalized attention for optimal career development in the tech industry.

+91 97879 68375

-> You should bring your own laptop during the internship

Who can apply?

Internships are open for students who: B.E / B.Tech / M.E / M.Tech / B.Sc / M.Sc / M.C.A / B.C.A / Diploma.

  • Ongoing Students Only
  • days, 5days/ 10days or Based on Student Preference
  • Limited 1 to 10 students per slot
  • Registration fees : 1000 INR
  • Slots are filling quickly only fewer slots are available