Thursday, August 29, 2024

Perfect Number by using For_loop

 # Python progam --- Perfect Number by using For_loop

Input_Number = int(input("enter a number"))

Sum = 0

for i in range(1, Input_Number):

    if(Input_Number % i == 0):

        Sum = Sum + i

if (Sum == Input_Number):

    print("Number is a Perfect Number.")

else:

    print("Number is not a Perfect Number.")

No comments:

Post a Comment