## Need help plz

This is the place for queries that don't fit in any of the other categories.

### Need help plz

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 greatestwhile True:    N = int(input("Enter N:"))    if 1 <= N <= 100:        break    else :        print("Please enter only numbers in the range [1,100].")i = 0print("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 darwinType "copyright", "credits" or "license()" for more information.>>> ================================ RESTART ================================>>> Enter N:9The 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.
xjaram1

Posts: 1
Joined: Sat Aug 24, 2013 9:37 pm

### Re: Need help plz

Try using a for loop instead of a while loop, to start. That always simplifies things.
Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

micseydel

Posts: 2118
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA