- 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

>>>