Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Practice

Instruction

Good job! How about this one?

Exercise

Write a program that will ask for a positive integer and print all of its divisors, one by one, on separate lines in ascending order.

A divisor is a number that divides a particular number with no remainder. For example, the divisors of 4 are 1, 2, and 4.

To check if a number a is a divisor of a number b, you can use the modulo operator %. a % b returns the remainder of dividing a by b. For example, 9 % 2 is 1 because 9 = 4 * 2 + 1, and 9 % 3 is 0 because 9 = 3 * 3 + 0. If a % b == 0, then b is a divisor of a.

Stuck? Here's a hint!

You should iterate over the numbers from 1 to number and check each number to determine whether it's a divisor of the number:

for i in range(1, number + 1):
  ...

The range(a, b) function returns a sequence starting with a and ending with b - 1.