by **xjaram1** » Tue Sep 17, 2013 4:51 pm

I need help with my code, I have most done I just can't get my divisors to be in order from least to greatest. I tried making i = N then i = i - 1 that doesn't give me 9/9 but 9/3 and 9/1. Any help will be appreciated.

- Code: Select all
`#This program gets a integer from the user in the range of 1 and 100.`

#The program will make sure the integer is between that range, and it will then list the divisors of N.

#In order least to greatest

while True:

N = int(input("Enter N:"))

if 1 <= N <= 100:

break

else :

print("Please enter only numbers in the range [1,100].")

i = 0

print("The divisors of",N,"are:",end = " ")

while 1 <= N <= 100:

i = i + 1

if N%i == 0:

print(N//i,end = " ")

#div = N//i

#print(div, end = " ")

if i == N:

break

- Code: Select all
`SHELL:`

Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 12:45:22)

[GCC 4.2.1 (Apple Inc. build 5577)] on darwin

Type "copyright", "credits" or "license()" for more information.

>>> ================================ RESTART ================================

>>>

Enter N:9

The divisors of 9 are: 9 3 1

>>>

Last edited by

micseydel on Tue Sep 17, 2013 5:29 pm, edited 1 time in total.

**Reason:** *First post lock.*