i try to count divisor if number have 4 divisors will print “elegant number” else “not elegant number” but i have trouble while print it i have finished to show divisors from number but my program can’t show elegant number or not. i have your opinion to fixed it. here my code:

N = int(input("enter number: ")) i = 1 factor = 0 # this for count divisors but doesn't right while (i <= N): if(N%i==0): print(i) factor+=i # this for count divisors but doesn't right i+=1 if(factor==4): print("elegant number") else: print("not elegant number")

i have put comment in line which line for count divisors.

## Answer

I think the main issue inside the code was adding `factor += i`

instead of `factor += 1`

(to account for a new divisor).
Also, the placement of the `factor += 1`

condition had to be inside the `if-statement`

.

Here is an updated version of the code:

N = int(input("enter number: ")) factors = 0 for i in range(1,N+1): # Add N+1 to loop over "i=N" as well if N%i == 0: print(i) factors += 1 if factors == 4 : print("elegant number") else: print("not elegant number")

Please let me know in the comments section if you need further help. Cheers,

PS. Alternative version using a `while-loop`

:

N = int(input("enter number: ")) factors = 0 i = 1 while i<=N: if N%i == 0: print(i) factors += 1 i += 1 if factors == 4 : print("elegant number") else: print("not elegant number")